--<ScriptOptions statementTerminator=";"/>

CREATE BUFFERPOOL "IBMDEFAULTBP"	IMMEDIATE
	ALL DBPARTITIONNUMS  SIZE 250
	NUMBLOCKPAGES 0
	PAGESIZE 8 K;

CREATE SCHEMA "AJAY" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "DB2ADMIN" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "NULLID" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SQLJ" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSCAT" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSFUN" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSIBM" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSIBMADM" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSIBMINTERNAL" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSIBMTS" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSPROC" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSPUBLIC" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSSTAT" AUTHORIZATION "SYSIBM";

CREATE SCHEMA "SYSTOOLS" AUTHORIZATION "SYSIBM";

CREATE DISTINCT TYPE "SYSPROC"."DB2SECURITYLABEL" AS VARCHAR (128) FOR BIT DATA WITH COMPARISONS;

CREATE DISTINCT TYPE "SYSPROC"."DB2SQLSTATE" AS CHAR(5) WITH COMPARISONS;

CREATE SEQUENCE "AJAY"."SAMPSEQUENCE" AS BIGINT  START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 NO CYCLE CACHE 20 NO ORDER;

CREATE TABLE "AJAY"."ACT" (
		"ACTNO" SMALLINT NOT NULL, 
		"ACTKWD" CHAR(6) NOT NULL, 
		"ACTDESC" VARCHAR(20) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."CATALOG" (
		"NAME" VARCHAR(128) NOT NULL, 
		"CATLOG" XML
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."CL_SCHED" (
		"CLASS_CODE" CHAR(7), 
		"DAY" SMALLINT, 
		"STARTING" TIME, 
		"ENDING" TIME
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."CUSTOMER" (
		"CID" BIGINT NOT NULL, 
		"INFO" XML, 
		"HISTORY" XML
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."DEPARTMENT" (
		"DEPTNO" CHAR(3) NOT NULL, 
		"DEPTNAME" VARCHAR(36) NOT NULL, 
		"MGRNO" CHAR(6), 
		"ADMRDEPT" CHAR(3) NOT NULL, 
		"LOCATION" CHAR(16)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."EMPLOYEE" (
		"EMPNO" CHAR(6) NOT NULL, 
		"FIRSTNME" VARCHAR(12) NOT NULL, 
		"MIDINIT" CHAR(1), 
		"LASTNAME" VARCHAR(15) NOT NULL, 
		"WORKDEPT" CHAR(3), 
		"PHONENO" CHAR(4), 
		"HIREDATE" DATE, 
		"JOB" CHAR(8), 
		"EDLEVEL" SMALLINT NOT NULL, 
		"SEX" CHAR(1), 
		"BIRTHDATE" DATE, 
		"SALARY" DECIMAL(9 , 2), 
		"BONUS" DECIMAL(9 , 2), 
		"COMM" DECIMAL(9 , 2)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."EMPMDC" (
		"EMPNO" INTEGER, 
		"DEPT" INTEGER, 
		"DIV" INTEGER
	)
	ORGANIZE BY DIMENSIONS (
	("DEPT"),  
	("DIV"))
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."EMPPROJACT" (
		"EMPNO" CHAR(6) NOT NULL, 
		"PROJNO" CHAR(6) NOT NULL, 
		"ACTNO" SMALLINT NOT NULL, 
		"EMPTIME" DECIMAL(5 , 2), 
		"EMSTDATE" DATE, 
		"EMENDATE" DATE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."EMP_PHOTO" (
		"EMPNO" CHAR(6) NOT NULL, 
		"PHOTO_FORMAT" VARCHAR(10) NOT NULL, 
		"PICTURE" BLOB(102400) INLINE LENGTH 140
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."EMP_RESUME" (
		"EMPNO" CHAR(6) NOT NULL, 
		"RESUME_FORMAT" VARCHAR(10) NOT NULL, 
		"RESUME" CLOB(5120) INLINE LENGTH 92
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."INVENTORY" (
		"PID" VARCHAR(10) NOT NULL, 
		"QUANTITY" INTEGER, 
		"LOCATION" VARCHAR(128)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."IN_TRAY" (
		"RECEIVED" TIMESTAMP, 
		"SOURCE" CHAR(8), 
		"SUBJECT" CHAR(64), 
		"NOTE_TEXT" VARCHAR(3000)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."ORG" (
		"DEPTNUMB" SMALLINT NOT NULL, 
		"DEPTNAME" VARCHAR(14), 
		"MANAGER" SMALLINT, 
		"DIVISION" VARCHAR(10), 
		"LOCATION" VARCHAR(13)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."PRODUCT" (
		"PID" VARCHAR(10) NOT NULL, 
		"NAME" VARCHAR(128), 
		"PRICE" DECIMAL(30 , 2), 
		"PROMOPRICE" DECIMAL(30 , 2), 
		"PROMOSTART" DATE, 
		"PROMOEND" DATE, 
		"DESCRIPTION" XML
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."PRODUCTSUPPLIER" (
		"PID" VARCHAR(10) NOT NULL, 
		"SID" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."PROJACT" (
		"PROJNO" CHAR(6) NOT NULL, 
		"ACTNO" SMALLINT NOT NULL, 
		"ACSTAFF" DECIMAL(5 , 2), 
		"ACSTDATE" DATE NOT NULL, 
		"ACENDATE" DATE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."PROJECT" (
		"PROJNO" CHAR(6) NOT NULL, 
		"PROJNAME" VARCHAR(24) NOT NULL DEFAULT '', 
		"DEPTNO" CHAR(3) NOT NULL, 
		"RESPEMP" CHAR(6) NOT NULL, 
		"PRSTAFF" DECIMAL(5 , 2), 
		"PRSTDATE" DATE, 
		"PRENDATE" DATE, 
		"MAJPROJ" CHAR(6)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."PURCHASEORDER" (
		"POID" BIGINT NOT NULL, 
		"STATUS" VARCHAR(10) NOT NULL DEFAULT 'Unshipped', 
		"CUSTID" BIGINT, 
		"ORDERDATE" DATE, 
		"PORDER" XML, 
		"COMMENTS" VARCHAR(1000)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."SALES" (
		"SALES_DATE" DATE, 
		"SALES_PERSON" VARCHAR(15), 
		"REGION" VARCHAR(15), 
		"SALES" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."STAFF" (
		"ID" SMALLINT NOT NULL, 
		"NAME" VARCHAR(9), 
		"DEPT" SMALLINT, 
		"JOB" CHAR(5), 
		"YEARS" SMALLINT, 
		"SALARY" DECIMAL(7 , 2), 
		"COMM" DECIMAL(7 , 2)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."STAFFG" (
		"ID" SMALLINT NOT NULL, 
		"NAME" VARGRAPHIC(9), 
		"DEPT" SMALLINT, 
		"JOB" GRAPHIC(5), 
		"YEARS" SMALLINT, 
		"SALARY" DECIMAL(9 , 0), 
		"COMM" DECIMAL(9 , 0)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "AJAY"."SUPPLIERS" (
		"SID" VARCHAR(10) NOT NULL, 
		"ADDR" XML
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ABBREVIATION" (
		"ABB_TEXT" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ADDRESS" (
		"ADID" INTEGER NOT NULL, 
		"STREET" VARCHAR(100), 
		"CITY" VARCHAR(15), 
		"COUNTRY" VARCHAR(15), 
		"NUMBER" VARCHAR(15)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AGENT" (
		"AGENTID" VARCHAR(32) NOT NULL, 
		"ADDRESS" VARCHAR(32), 
		"CONTACTNO" VARCHAR(32), 
		"COUNTRY" VARCHAR(32), 
		"LNAME" VARCHAR(32), 
		"FNAME" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AIRLINE" (
		"ALID" INTEGER NOT NULL, 
		"ANAME" VARCHAR(32) NOT NULL, 
		"ABB_TEXT" CHAR(10) NOT NULL, 
		"LOGO" BLOB(1048576) INLINE LENGTH 164, 
		"ADID" INTEGER NOT NULL, 
		"CFID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AIRPLANE" (
		"APID" INTEGER NOT NULL, 
		"ATID" INTEGER NOT NULL, 
		"ALID" INTEGER NOT NULL, 
		"MANUFACTURE_DATE" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AIRPLANETYPE" (
		"ATID" INTEGER NOT NULL, 
		"ATYPE" VARCHAR(10) NOT NULL, 
		"MANUFACTURER" VARCHAR(150) NOT NULL, 
		"NO_OF_SEATS" SMALLINT NOT NULL, 
		"ECONOMY_SEATS_NUM" SMALLINT NOT NULL, 
		"FIRSTCLASS_SEATS_NUM" SMALLINT NOT NULL, 
		"BUSINESS_SEATS_NUM" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AIRPORT" (
		"APCODE" CHAR(3) NOT NULL, 
		"APNAME" VARCHAR(200) NOT NULL, 
		"CITY" VARCHAR(20), 
		"COUNTRY" VARCHAR(25)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AREA" (
		"AREAID" INTEGER NOT NULL, 
		"AREANUMBER" SMALLINT NOT NULL, 
		"APCODE" CHAR(3) NOT NULL, 
		"ANAME" VARCHAR(32), 
		"ALOCATION" VARCHAR(100), 
		"SIZE" INTEGER, 
		"AASSIGNMENT" VARCHAR(150), 
		"ARENT" DOUBLE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."AREA_RENTED_BY" (
		"AREAID" INTEGER NOT NULL, 
		"TENANTID" INTEGER NOT NULL, 
		"RENTSTARTDATE" DATE NOT NULL, 
		"RENTENDDATE" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ASSIGNED_TO_CATERING_FACILITY" (
		"KSID" INTEGER NOT NULL, 
		"CFID" INTEGER NOT NULL, 
		"STARTTIMESTAMP" TIMESTAMP NOT NULL, 
		"ENDTIMESTAMP" TIMESTAMP
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ATTACHES_WITH" (
		"BOARDINGPASSID" VARCHAR(32) NOT NULL, 
		"LUGGAGEID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ATTENDENT" (
		"ATT_ID" SMALLINT NOT NULL, 
		"CREW_ID" INTEGER NOT NULL, 
		"CMID" INTEGER NOT NULL, 
		"RANK" VARCHAR(15)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."BOARDINGPASS" (
		"BOARDINGPASSID" VARCHAR(32) NOT NULL, 
		"GATE" VARCHAR(32) NOT NULL, 
		"SEATNO" VARCHAR(32), 
		"SEGMENTTICKETID" VARCHAR(32), 
		"PASSENGERID" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CATERING" (
		"CATID" VARCHAR(32) NOT NULL, 
		"CATNAME" VARCHAR(32), 
		"ISLAMIC" CHAR(1), 
		"BABY" CHAR(1), 
		"ALCOHOL" CHAR(1), 
		"MENUPRICE" DOUBLE, 
		"CATWEIGHT" DOUBLE, 
		"VEGETARIAN" CHAR(1), 
		"CATTYPE" VARCHAR(32), 
		"ISADDITION" CHAR(1)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CATERINGFACILITY" (
		"CFID" INTEGER NOT NULL, 
		"CFNAME" VARCHAR(30), 
		"APCODE" CHAR(3) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CHECKIN" (
		"CHKINCOUNTERNR" INTEGER NOT NULL, 
		"PASSENGERID" VARCHAR(32) NOT NULL, 
		"CHECKINTIME" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CHECKINCOUNTER" (
		"CHKINCOUNTERNR" INTEGER NOT NULL, 
		"CLOCATION" VARCHAR(10), 
		"APCODE" CHAR(3) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CHECKINPERSONNEL" (
		"CHPID" INTEGER NOT NULL, 
		"PSID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CMEM_HAS_ADMISSION" (
		"CMID" INTEGER NOT NULL, 
		"ATID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CODE_DEFINITION" (
		"CODE" SMALLINT NOT NULL, 
		"DEFINITION" VARCHAR(300) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CONTACTS" (
		"CUSTOMERID" VARCHAR(32) NOT NULL, 
		"AGENTID" VARCHAR(32) NOT NULL, 
		"CURRENCY" VARCHAR(32), 
		"STATUS" VARCHAR(32), 
		"MODEOFPAYMENT" VARCHAR(32), 
		"AMOUNT" DOUBLE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CREW" (
		"CREW_ID" INTEGER NOT NULL, 
		"NUM_OF_PILOTS" SMALLINT NOT NULL, 
		"NUM_OF_ATTENDANTS" SMALLINT
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CREW_MEMBER" (
		"CMID" INTEGER NOT NULL, 
		"PSID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."CUSTOMER" (
		"CUSTOMERID" VARCHAR(32) NOT NULL, 
		"FNAME" VARCHAR(32), 
		"LNAME" VARCHAR(32), 
		"ADDRESS" VARCHAR(32), 
		"COUNTRY" VARCHAR(32), 
		"PASSPORTNO" VARCHAR(32), 
		"DOB" DATE, 
		"SEX" CHAR(3)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."DELAY" (
		"DID" INTEGER NOT NULL, 
		"DURATION" TIME NOT NULL, 
		"DESCRIPTION" VARCHAR(32) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FARE" (
		"TYPE" VARCHAR(32) NOT NULL, 
		"FARE" VARCHAR(32) NOT NULL, 
		"CURRENCY" VARCHAR(32) NOT NULL, 
		"DISCOUNT" DOUBLE NOT NULL, 
		"TOTALFARE" DOUBLE NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FLIGHT" (
		"FLIGHTID" VARCHAR(32) NOT NULL, 
		"SOURCE_CITY" VARCHAR(32), 
		"DESTINATION_CITY" VARCHAR(32) NOT NULL, 
		"ARRIVAL_TIME" TIME, 
		"ARRIVAL_DATE" DATE, 
		"DEPARTURE_TIME" TIME, 
		"DEPARTURE_DATE" DATE, 
		"COLUMN8" CHAR(5)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FLIGHTCONTROLLER" (
		"FCONTROLLERID" VARCHAR(32) NOT NULL, 
		"FCNAME" VARCHAR(32) NOT NULL, 
		"FCSURNAME" VARCHAR(32) NOT NULL, 
		"FCADDRESS" VARCHAR(32) NOT NULL, 
		"FCPHONE" VARCHAR(32) NOT NULL, 
		"FCEMAIL" VARCHAR(32) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FLIGHTSEGMENT" (
		"FLIGHTNR" VARCHAR(10) NOT NULL, 
		"CREW_ID" INTEGER, 
		"APID" INTEGER, 
		"ARRIVAL_TIME" TIME, 
		"ARRIVAL_DATE" DATE, 
		"DEPARTURE_TIME" TIME, 
		"DEPARTURE_DATE" DATE, 
		"SOURCE_CITY" VARCHAR(32), 
		"DESTINATION_CITY" VARCHAR(32), 
		"ROUTEID" VARCHAR(32)
	)
	DATA CAPTURE CHANGES 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FLIGHT_CONSISTS_OF" (
		"FLIGHTID" VARCHAR(32) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."FLIGHT_ORDERS" (
		"ORDER_NO" INTEGER NOT NULL, 
		"CATID" VARCHAR(32) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL, 
		"ORDERQUANTITY" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."HISTORY" (
		"TENANTID" INTEGER NOT NULL, 
		"HRENTSTARTDATE" DATE NOT NULL, 
		"HRENTENDDATE" DATE, 
		"HASSIGNMENT" VARCHAR(150), 
		"HNAME" VARCHAR(25) NOT NULL, 
		"HRENT" DOUBLE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."INCLUDES" (
		"CATID" VARCHAR(32) NOT NULL, 
		"SEGMENTTICKETID" VARCHAR(32) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."KITCHEN_STAFF" (
		"KSID" INTEGER NOT NULL, 
		"PSID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."LUGGAGE" (
		"LUGGAGEID" INTEGER NOT NULL, 
		"ISSTORED" CHAR(1) NOT NULL, 
		"PRIORIRY" SMALLINT, 
		"LWEIGHT" DOUBLE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."LUGGAGE_TAGGED_BY" (
		"LUGGAGEID" INTEGER NOT NULL, 
		"CHKINCOUNTERNR" INTEGER NOT NULL, 
		"APCODE" CHAR(3) NOT NULL, 
		"TAGTIMESTAMP" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."MAINTENANCEPERSONNEL" (
		"MPID" INTEGER NOT NULL, 
		"PSID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."M_WORKS_IN" (
		"MPID" INTEGER NOT NULL, 
		"APCODE" CHAR(3) NOT NULL, 
		"STARTTIMESTAMP" TIMESTAMP NOT NULL, 
		"ENDTIMESTAMP" TIMESTAMP
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ORDERED_BY" (
		"CATID" VARCHAR(32) NOT NULL, 
		"CUSTOMERID" VARCHAR(32) NOT NULL, 
		"ORDERQUANTITY" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PARKINGSLOT" (
		"APCODE" CHAR(3) NOT NULL, 
		"PARKINGSLOTID" VARCHAR(32) NOT NULL, 
		"PAVAILABILITY" VARCHAR(32) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PARKINGSLOTLOG" (
		"PARKINGSLOTID" INTEGER NOT NULL, 
		"PARKINGTIMESTAMP" TIMESTAMP NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PARKINGSLOT_ASSIGNED_TO" (
		"PS_TIMESTAMP" TIMESTAMP NOT NULL, 
		"APCODE" CHAR(3) NOT NULL, 
		"PARKINGSLOTID" VARCHAR(32) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PASSENGER" (
		"PASSENGERID" VARCHAR(32) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PERSON" (
		"PID" INTEGER NOT NULL, 
		"BIRTHPLACE" VARCHAR(15), 
		"FIRST_NAME" VARCHAR(15) NOT NULL, 
		"LAST_NAME" VARCHAR(15) NOT NULL, 
		"SSN" INTEGER NOT NULL, 
		"GENDER" CHAR(1) NOT NULL, 
		"NATIONALITY" VARCHAR(20) NOT NULL, 
		"BIRTH_DATE" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PERSONNEL" (
		"PSID" INTEGER NOT NULL, 
		"PID" INTEGER NOT NULL, 
		"WORK_START_DATE" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PERSONNEL_ASSIGNED_TO_CHECKIN" (
		"CHPID" INTEGER NOT NULL, 
		"CHKINCOUNTERNR" INTEGER NOT NULL, 
		"STARTTIMESTAMP" TIMESTAMP NOT NULL, 
		"ENDTIMESTAMP" TIMESTAMP
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PILOT" (
		"PILOT_ID" SMALLINT NOT NULL, 
		"CREW_ID" INTEGER NOT NULL, 
		"CMID" INTEGER NOT NULL, 
		"RANK" VARCHAR(15)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."PROVIDE" (
		"CATID" VARCHAR(32) NOT NULL, 
		"CFID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."ROUTE" (
		"ROUTEID" VARCHAR(32) NOT NULL, 
		"DISTANCE" VARCHAR(32) NOT NULL, 
		"APCODE_SRC" CHAR(3) NOT NULL, 
		"APCODE_DST" CHAR(3) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."RUNWAY" (
		"APCODE" CHAR(3) NOT NULL, 
		"RUNWAYNR" VARCHAR(32) NOT NULL, 
		"RAVAILABILITY" VARCHAR(32) NOT NULL, 
		"FCONTROLLERID" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."RUNWAYLOG" (
		"RUNWAYNR" INTEGER NOT NULL, 
		"RUNWAYTIMESTAMP" TIMESTAMP NOT NULL, 
		"FCONTROLLERID" VARCHAR(32), 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."RUNWAY_USED_BY" (
		"RW_TIMESTAMP" TIMESTAMP NOT NULL, 
		"RUNWAYNR" VARCHAR(32) NOT NULL, 
		"APCODE" CHAR(3) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."SCHEDULEDMAINTENANCE" (
		"SMID" INTEGER NOT NULL, 
		"APID" INTEGER NOT NULL, 
		"PROC_TIMESTAMP" TIMESTAMP, 
		"PROC_DESCRIPTION" VARCHAR(55)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."SEATS" (
		"SNUMBER" SMALLINT NOT NULL, 
		"ATID" INTEGER NOT NULL, 
		"TYPE_OF_SEAT" VARCHAR(150)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."SEGMENTTICKET" (
		"SEGMENTTICKETID" VARCHAR(32) NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."TECHNICAL_NOTE" (
		"TNID" INTEGER NOT NULL, 
		"MPID" INTEGER NOT NULL, 
		"CODE" SMALLINT NOT NULL, 
		"FLIGHTNR" VARCHAR(10) NOT NULL, 
		"TN_TYPE" CHAR(1), 
		"DESCRIPTION" VARCHAR(200)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."TENANT" (
		"TENANTID" INTEGER NOT NULL, 
		"TNAME" VARCHAR(25) NOT NULL, 
		"BANKACCOUNT" VARCHAR(20) NOT NULL, 
		"TEMAIL" VARCHAR(40), 
		"TPHONE" VARCHAR(10)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."TICKET" (
		"TICKETID" VARCHAR(32) NOT NULL, 
		"FLIGHTID" VARCHAR(32) NOT NULL, 
		"TOTALFARE" DOUBLE, 
		"NOOFCHILDREN" INTEGER, 
		"DEPARTURETIME" TIME, 
		"DEPARTUREDATE" DATE, 
		"DEPARTUREAIRPORTCODE" CHAR(3), 
		"CURRENCY" VARCHAR(32), 
		"ARRIVALAIRPORTCODE" CHAR(3), 
		"ARRIVALTIME" TIME, 
		"ARRIVALDATE" DATE, 
		"CUSTOMERID" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."TICKET_CONSISTS_SEGMENT" (
		"TICKETID" VARCHAR(32) NOT NULL, 
		"SEGMENTTICKETID" VARCHAR(32) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "DB2ADMIN"."TRANSACTIONS" (
		"AGENTID" VARCHAR(32) NOT NULL, 
		"FLIGHTID" VARCHAR(32) NOT NULL, 
		"T_TIMESTAMP" TIMESTAMP, 
		"CURRENCY" VARCHAR(32), 
		"T_STATUS" VARCHAR(32), 
		"MODEOFPAYMENT" VARCHAR(32), 
		"AMOUNT" DOUBLE, 
		"TYPEOFTRANSACTION" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSATTRIBUTES" (
		"TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"TYPENAME" VARCHAR(128) NOT NULL, 
		"ATTR_NAME" VARCHAR(128) NOT NULL, 
		"ATTR_TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"ATTR_TYPENAME" VARCHAR(128) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"LENGTH" INTEGER NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"LOGGED" CHAR(1) NOT NULL, 
		"COMPACT" CHAR(1) NOT NULL, 
		"TARGET_TYPESCHEMA" VARCHAR(128), 
		"TARGET_TYPENAME" VARCHAR(128), 
		"SOURCE_TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"SOURCE_TYPENAME" VARCHAR(128) NOT NULL, 
		"JAVA_FIELDNAME" VARCHAR(256), 
		"COLLATIONID" CHAR (8) FOR BIT DATA, 
		"TYPEMODULEID" INTEGER, 
		"ATTR_TYPEMODULEID" INTEGER, 
		"TARGET_TYPEMODULEID" INTEGER, 
		"SOURCE_TYPEMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSAUDITPOLICIES" (
		"AUDITPOLICYNAME" VARCHAR(128) NOT NULL, 
		"AUDITPOLICYID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"AUDITSTATUS" CHAR(1) NOT NULL, 
		"CONTEXTSTATUS" CHAR(1) NOT NULL, 
		"VALIDATESTATUS" CHAR(1) NOT NULL, 
		"CHECKINGSTATUS" CHAR(1) NOT NULL, 
		"SECMAINTSTATUS" CHAR(1) NOT NULL, 
		"OBJMAINTSTATUS" CHAR(1) NOT NULL, 
		"SYSADMINSTATUS" CHAR(1) NOT NULL, 
		"EXECUTESTATUS" CHAR(1) NOT NULL, 
		"EXECUTEWITHDATA" CHAR(1) NOT NULL, 
		"ERRORTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSAUDITUSE" (
		"OBJECTNAME" VARCHAR(128) NOT NULL, 
		"OBJECTTYPE" CHAR(1) NOT NULL, 
		"SUBOBJECTTYPE" CHAR(1) NOT NULL, 
		"AUDITPOLICYID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSBUFFERPOOLNODES" (
		"BUFFERPOOLID" INTEGER NOT NULL, 
		"NODENUM" SMALLINT NOT NULL, 
		"NPAGES" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSBUFFERPOOLS" (
		"BPNAME" VARCHAR(128) NOT NULL, 
		"BUFFERPOOLID" INTEGER NOT NULL, 
		"NGNAME" VARCHAR(128), 
		"NPAGES" INTEGER NOT NULL, 
		"PAGESIZE" INTEGER NOT NULL, 
		"NUMBLOCKPAGES" INTEGER NOT NULL, 
		"BLOCKSIZE" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCHECKS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92 NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"QUALIFIER" VARCHAR(128) NOT NULL, 
		"TYPE" CHAR(1) NOT NULL, 
		"PERCENTVALID" SMALLINT NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCODEPROPERTIES" (
		"OBJECT_TYPE" CHAR(1) NOT NULL, 
		"OBJECT_ID" INTEGER NOT NULL, 
		"LIB_ID" INTEGER, 
		"LIBVERSION" INTEGER, 
		"TRACE_LEVEL" CHAR(1) NOT NULL, 
		"DIAGNOSTIC_LEVEL" CHAR(1) NOT NULL, 
		"DEBUG_DATA" CLOB(1048576) INLINE LENGTH 164, 
		"CHECKOUT_USERID" VARCHAR(128), 
		"PRECOMPILE_OPTIONS" VARCHAR(1024), 
		"COMPILE_OPTIONS" VARCHAR(1024), 
		"SQL_COMPILED_CODE" BLOB(10485760) INLINE LENGTH 196
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"TNAME" VARCHAR(128) NOT NULL, 
		"PRIVTYPE" CHAR(1) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"GRANTABLE" CHAR(1) NOT NULL, 
		"COLNO" SMALLINT NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLCHECKS" (
		"CONSTNAME" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"USAGE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLDIST" (
		"NAME" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"SCHEMA" VARCHAR(128) NOT NULL, 
		"TYPE" CHAR(1) NOT NULL, 
		"SEQNO" SMALLINT NOT NULL, 
		"COLVALUE" VARCHAR(254), 
		"VALCOUNT" BIGINT NOT NULL, 
		"DISTCOUNT" BIGINT
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLGROUPDIST" (
		"COLGROUPID" INTEGER NOT NULL, 
		"TYPE" CHAR(1) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"SEQNO" SMALLINT NOT NULL, 
		"COLVALUE" VARCHAR(254) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLGROUPDISTCOUNTS" (
		"COLGROUPID" INTEGER NOT NULL, 
		"TYPE" CHAR(1) NOT NULL, 
		"SEQNO" SMALLINT NOT NULL, 
		"VALCOUNT" BIGINT NOT NULL, 
		"DISTCOUNT" BIGINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLGROUPS" (
		"COLGROUPSCHEMA" VARCHAR(128) NOT NULL, 
		"COLGROUPNAME" VARCHAR(128) NOT NULL, 
		"COLGROUPID" INTEGER NOT NULL, 
		"COLGROUPCARD" BIGINT NOT NULL, 
		"NUMFREQ_VALUES" SMALLINT NOT NULL, 
		"NUMQUANTILES" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLGROUPSCOLS" (
		"COLGROUPID" INTEGER NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLLATIONS" (
		"COLLATIONSCHEMA" VARCHAR(128) NOT NULL, 
		"COLLATIONNAME" VARCHAR(128) NOT NULL, 
		"OBJECTID" INTEGER NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"SOURCECOLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"OWNERTYPE" CHAR(1) NOT NULL, 
		"COLLATION_DESC" BLOB(2097152) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLOPTIONS" (
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" CLOB(32768) INLINE LENGTH 116 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLPROPERTIES" (
		"COLNAME" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TARGET_TYPESCHEMA" VARCHAR(128), 
		"TARGET_TYPENAME" VARCHAR(128), 
		"SCOPE_TABSCHEMA" VARCHAR(128), 
		"SCOPE_TABNAME" VARCHAR(128), 
		"SPECIAL_PROPS" CHAR(8) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLUMNS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"COLTYPE" CHAR(8) NOT NULL, 
		"NULLS" CHAR(1) NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"DBCSCODEPG" SMALLINT NOT NULL, 
		"LENGTH" SMALLINT NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"COLNO" SMALLINT NOT NULL, 
		"COLCARD" BIGINT NOT NULL, 
		"HIGH2KEY" VARCHAR(254), 
		"LOW2KEY" VARCHAR(254), 
		"AVGCOLLEN" INTEGER NOT NULL, 
		"KEYSEQ" SMALLINT, 
		"TYPENAME" VARCHAR(128) NOT NULL, 
		"TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"DEFAULT" VARCHAR(254), 
		"LONGLENGTH" INTEGER NOT NULL, 
		"LOGGED" CHAR(1) NOT NULL, 
		"COMPACT" CHAR(1) NOT NULL, 
		"NQUANTILES" SMALLINT NOT NULL, 
		"NMOSTFREQ" SMALLINT NOT NULL, 
		"COMPOSITE_CODEPAGE" SMALLINT NOT NULL, 
		"PARTKEYSEQ" SMALLINT, 
		"SOURCE_TABSCHEMA" VARCHAR(128), 
		"SOURCE_TABNAME" VARCHAR(128), 
		"HIDDEN" CHAR(1) NOT NULL, 
		"GENERATED" CHAR(1) NOT NULL, 
		"INLINE_LENGTH" INTEGER NOT NULL, 
		"NUMNULLS" BIGINT NOT NULL, 
		"AVGCOLLENCHAR" INTEGER NOT NULL, 
		"SUB_COUNT" SMALLINT NOT NULL, 
		"SUB_DELIM_LENGTH" SMALLINT NOT NULL, 
		"IDENTITY" CHAR(1) NOT NULL, 
		"COMPRESS" CHAR(1) NOT NULL, 
		"AVGDISTINCTPERPAGE" DOUBLE, 
		"PAGEVARIANCERATIO" DOUBLE, 
		"IMPLICITVALUE" VARCHAR(254), 
		"SECLABELID" INTEGER NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA, 
		"PCTINLINED" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOLUSE" (
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"DIMENSION" SMALLINT NOT NULL, 
		"COLSEQ" SMALLINT NOT NULL, 
		"TYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCOMMENTS" (
		"OBJECTID" BIGINT NOT NULL, 
		"REMARKS" VARCHAR(254) NOT NULL, 
		"OBJECTTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCONSTDEP" (
		"BNAME" VARCHAR(128) NOT NULL, 
		"BCREATOR" VARCHAR(128) NOT NULL, 
		"BTYPE" CHAR(1) NOT NULL, 
		"DTBNAME" VARCHAR(128) NOT NULL, 
		"DTBCREATOR" VARCHAR(128) NOT NULL, 
		"DCONSTNAME" VARCHAR(128) NOT NULL, 
		"BMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCONTEXTATTRIBUTES" (
		"CONTEXTID" INTEGER NOT NULL, 
		"ATTR_NAME" VARCHAR(128) NOT NULL, 
		"ATTR_TYPE" SMALLINT NOT NULL, 
		"ATTR_VALUE" VARCHAR(128) NOT NULL, 
		"ATTR_OPTIONS" VARCHAR(128)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSCONTEXTS" (
		"CONTEXTNAME" VARCHAR(128) NOT NULL, 
		"CONTEXTID" INTEGER NOT NULL, 
		"SYSTEMAUTHID" VARCHAR(128) NOT NULL, 
		"DEFAULTCONTEXTROLE" VARCHAR(128), 
		"ROLEASOBJECTOWNER" CHAR(1) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"CONTEXT_DESC" BLOB(65536) INLINE LENGTH 116, 
		"AUDITPOLICYID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSDATAPARTITIONEXPRESSION" (
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"DATAPARTITIONKEYSEQ" INTEGER NOT NULL, 
		"DATAPARTITIONEXPRESSION" CLOB(32768) INLINE LENGTH 116 NOT NULL, 
		"NULLSFIRST" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSDATAPARTITIONS" (
		"DATAPARTITIONNAME" VARCHAR(128) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"DATAPARTITIONID" INTEGER NOT NULL, 
		"TBSPACEID" INTEGER, 
		"PARTITIONOBJECTID" INTEGER, 
		"LONG_TBSPACEID" INTEGER, 
		"ACCESS_MODE" CHAR(1) NOT NULL, 
		"STATUS" VARCHAR(32) NOT NULL, 
		"SEQNO" INTEGER NOT NULL, 
		"LOWINCLUSIVE" CHAR(1) NOT NULL, 
		"LOWVALUE" VARCHAR(512) NOT NULL, 
		"HIGHINCLUSIVE" CHAR(1) NOT NULL, 
		"HIGHVALUE" VARCHAR(512) NOT NULL, 
		"ROWFORMATVERSION" SMALLINT NOT NULL, 
		"CARD" BIGINT NOT NULL, 
		"OVERFLOW" BIGINT NOT NULL, 
		"NPAGES" BIGINT NOT NULL, 
		"FPAGES" BIGINT NOT NULL, 
		"ACTIVE_BLOCKS" BIGINT NOT NULL, 
		"INDEX_TBSPACEID" INTEGER NOT NULL, 
		"AVGROWSIZE" SMALLINT NOT NULL, 
		"PCTROWSCOMPRESSED" REAL NOT NULL, 
		"PCTPAGESAVED" SMALLINT NOT NULL, 
		"AVGCOMPRESSEDROWSIZE" SMALLINT NOT NULL, 
		"AVGROWCOMPRESSIONRATIO" REAL NOT NULL, 
		"STATS_TIME" TIMESTAMP, 
		"LASTUSED" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSDATATYPES" (
		"NAME" VARCHAR(128) NOT NULL, 
		"SCHEMA" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"SOURCETYPE" VARCHAR(128), 
		"SOURCESCHEMA" VARCHAR(128), 
		"METATYPE" CHAR(1) NOT NULL, 
		"TYPEID" SMALLINT NOT NULL, 
		"SOURCETYPEID" SMALLINT, 
		"LENGTH" INTEGER NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"PACKED_DESC" BLOB(2097152) INLINE LENGTH 164, 
		"TYPE_DESC" BLOB(1048576) INLINE LENGTH 164, 
		"ATTRCOUNT" SMALLINT NOT NULL, 
		"INSTANTIABLE" CHAR(1) NOT NULL, 
		"WITH_FUNC_ACCESS" CHAR(1) NOT NULL, 
		"FINAL" CHAR(1) NOT NULL, 
		"INLINE_LENGTH" INTEGER NOT NULL, 
		"JARSCHEMA" VARCHAR(128), 
		"JAR_ID" VARCHAR(128), 
		"CLASS" VARCHAR(384), 
		"SQLJ_REPRESENTATION" CHAR(1), 
		"NATURAL_INLINE_LENGTH" INTEGER, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"ARRAY_LENGTH" INTEGER, 
		"COLLATIONID" CHAR (8) FOR BIT DATA, 
		"TYPEMODULEID" INTEGER, 
		"PUBLISHED" CHAR(1) NOT NULL, 
		"SOURCEMODULEID" INTEGER, 
		"VALID" CHAR(1) NOT NULL, 
		"ARRAYINDEXTYPEID" SMALLINT
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSDBAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"DBADMAUTH" CHAR(1) NOT NULL, 
		"CREATETABAUTH" CHAR(1) NOT NULL, 
		"BINDADDAUTH" CHAR(1) NOT NULL, 
		"CONNECTAUTH" CHAR(1) NOT NULL, 
		"NOFENCEAUTH" CHAR(1) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"IMPLSCHEMAAUTH" CHAR(1) NOT NULL, 
		"LOADAUTH" CHAR(1) NOT NULL, 
		"EXTERNALROUTINEAUTH" CHAR(1) NOT NULL, 
		"QUIESCECONNECTAUTH" CHAR(1) NOT NULL, 
		"SECURITYADMAUTH" CHAR(1) NOT NULL, 
		"LIBRARYADMAUTH" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER, 
		"SQLADMAUTH" CHAR(1) NOT NULL, 
		"WLMADMAUTH" CHAR(1) NOT NULL, 
		"EXPLAINAUTH" CHAR(1) NOT NULL, 
		"DATAACCESSAUTH" CHAR(1) NOT NULL, 
		"ACCESSCTRLAUTH" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSDEPENDENCIES" (
		"BNAME" VARCHAR(128) NOT NULL, 
		"BSCHEMA" VARCHAR(128) NOT NULL, 
		"BTYPE" CHAR(1) NOT NULL, 
		"DNAME" VARCHAR(128) NOT NULL, 
		"DSCHEMA" VARCHAR(128) NOT NULL, 
		"TABAUTH" SMALLINT, 
		"DTYPE" CHAR(1) NOT NULL, 
		"BUNIQUE_ID" CHAR (8) FOR BIT DATA, 
		"DOWNER" VARCHAR(128) NOT NULL, 
		"DOWNERTYPE" CHAR(1) NOT NULL, 
		"BMODULEID" INTEGER, 
		"DMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSEVENTMONITORS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"TARGET_TYPE" CHAR(1) NOT NULL, 
		"TARGET" VARCHAR(762) NOT NULL, 
		"MAXFILES" INTEGER, 
		"MAXFILESIZE" INTEGER, 
		"BUFFERSIZE" INTEGER, 
		"IO_MODE" CHAR(1), 
		"WRITE_MODE" CHAR(1), 
		"AUTOSTART" CHAR(1) NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"PACKED_DESC" BLOB(65536) INLINE LENGTH 116 NOT NULL, 
		"NODENUM" SMALLINT NOT NULL, 
		"MONSCOPE" CHAR(1) NOT NULL, 
		"EVMON_ACTIVATES" INTEGER NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"EVMONID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSEVENTS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"TYPE" VARCHAR(128) NOT NULL, 
		"FILTER" CLOB(65536) INLINE LENGTH 116
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSEVENTTABLES" (
		"EVMONNAME" VARCHAR(128) NOT NULL, 
		"LOGICAL_GROUP" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"PCTDEACTIVATE" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSFUNCMAPOPTIONS" (
		"FUNCTION_MAPPING" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSFUNCMAPPARMOPTIONS" (
		"FUNCTION_MAPPING" VARCHAR(128) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"LOCATION" CHAR(1) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSFUNCMAPPINGS" (
		"FUNCTION_MAPPING" VARCHAR(128) NOT NULL, 
		"FUNCSCHEMA" VARCHAR(128), 
		"FUNCNAME" VARCHAR(1024), 
		"FUNCID" INTEGER, 
		"SPECIFICNAME" VARCHAR(128), 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"SERVERNAME" VARCHAR(128), 
		"SERVERTYPE" VARCHAR(30), 
		"SERVERVERSION" VARCHAR(18), 
		"WRAPNAME" VARCHAR(128), 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSHIERARCHIES" (
		"METATYPE" CHAR(1) NOT NULL, 
		"SUB_SCHEMA" VARCHAR(128) NOT NULL, 
		"SUB_NAME" VARCHAR(128) NOT NULL, 
		"SUPER_SCHEMA" VARCHAR(128) NOT NULL, 
		"SUPER_NAME" VARCHAR(128) NOT NULL, 
		"ROOT_SCHEMA" VARCHAR(128) NOT NULL, 
		"ROOT_NAME" VARCHAR(128) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATEBINS" (
		"TEMPLATEID" INTEGER NOT NULL, 
		"BINID" INTEGER NOT NULL, 
		"BINUPPERVALUE" BIGINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATES" (
		"TEMPLATEID" INTEGER NOT NULL, 
		"TEMPLATENAME" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"NUMBINS" INTEGER NOT NULL, 
		"TEMPLATE_DESC" BLOB(8192) INLINE LENGTH 92
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATEUSE" (
		"TEMPLATEID" INTEGER NOT NULL, 
		"HISTOGRAMTYPE" CHAR(1) NOT NULL, 
		"OBJECTTYPE" CHAR(1) NOT NULL, 
		"OBJECTID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"CONTROLAUTH" CHAR(1) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXCOLUSE" (
		"INDSCHEMA" VARCHAR(128) NOT NULL, 
		"INDNAME" VARCHAR(128) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"COLSEQ" SMALLINT NOT NULL, 
		"COLORDER" CHAR(1) NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXES" (
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"COLNAMES" VARCHAR(640) NOT NULL, 
		"UNIQUERULE" CHAR(1) NOT NULL, 
		"COLCOUNT" SMALLINT NOT NULL, 
		"IID" SMALLINT NOT NULL, 
		"NLEAF" BIGINT NOT NULL, 
		"NLEVELS" SMALLINT NOT NULL, 
		"FIRSTKEYCARD" BIGINT NOT NULL, 
		"FULLKEYCARD" BIGINT NOT NULL, 
		"CLUSTERRATIO" SMALLINT NOT NULL, 
		"CLUSTERFACTOR" DOUBLE NOT NULL, 
		"USER_DEFINED" SMALLINT NOT NULL, 
		"SYSTEM_REQUIRED" SMALLINT NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"STATS_TIME" TIMESTAMP, 
		"PAGE_FETCH_PAIRS" VARCHAR(520) NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"MADE_UNIQUE" CHAR(1) NOT NULL, 
		"SEQUENTIAL_PAGES" BIGINT NOT NULL, 
		"DENSITY" INTEGER NOT NULL, 
		"FIRST2KEYCARD" BIGINT NOT NULL, 
		"FIRST3KEYCARD" BIGINT NOT NULL, 
		"FIRST4KEYCARD" BIGINT NOT NULL, 
		"PCTFREE" SMALLINT NOT NULL, 
		"UNIQUE_COLCOUNT" SMALLINT NOT NULL, 
		"INDEXTYPE" CHAR(4) NOT NULL, 
		"ENTRYTYPE" CHAR(1) NOT NULL, 
		"MINPCTUSED" SMALLINT NOT NULL, 
		"REVERSE_SCANS" CHAR(1) NOT NULL, 
		"IESCHEMA" VARCHAR(128), 
		"IENAME" VARCHAR(128), 
		"IEARGUMENTS" CLOB(65536) INLINE LENGTH 116, 
		"INDEX_DESC" BLOB(1048576) INLINE LENGTH 164, 
		"INTERNAL_FORMAT" SMALLINT NOT NULL, 
		"INDEX_OBJECTID" INTEGER NOT NULL, 
		"TBSPACEID" INTEGER NOT NULL, 
		"AVERAGE_SEQUENCE_GAP" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_FETCH_GAP" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_FETCH_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_RANDOM_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_RANDOM_FETCH_PAGES" DOUBLE NOT NULL, 
		"NUMRIDS" BIGINT NOT NULL, 
		"NUMRIDS_DELETED" BIGINT NOT NULL, 
		"NUM_EMPTY_LEAFS" BIGINT NOT NULL, 
		"OS_PTR_SIZE" INTEGER NOT NULL, 
		"LEVEL2PCTFREE" SMALLINT NOT NULL, 
		"PAGESPLIT" CHAR(1) NOT NULL, 
		"AVGPARTITION_CLUSTERRATIO" SMALLINT NOT NULL, 
		"AVGPARTITION_CLUSTERFACTOR" DOUBLE NOT NULL, 
		"AVGPARTITION_PAGE_FETCH_PAIRS" VARCHAR(520) NOT NULL, 
		"DATAPARTITION_CLUSTERFACTOR" DOUBLE NOT NULL, 
		"INDCARD" BIGINT NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"COLLECTSTATISTICS" CHAR(1) NOT NULL, 
		"COMPRESSION" CHAR(1) NOT NULL, 
		"PCTPAGESSAVED" SMALLINT NOT NULL, 
		"AVGLEAFKEYSIZE" INTEGER NOT NULL, 
		"AVGNLEAFKEYSIZE" INTEGER NOT NULL, 
		"LASTUSED" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXEXPLOITRULES" (
		"FUNCID" INTEGER NOT NULL, 
		"SPECID" SMALLINT NOT NULL, 
		"IESCHEMA" VARCHAR(128) NOT NULL, 
		"IENAME" VARCHAR(128) NOT NULL, 
		"RULEID" SMALLINT NOT NULL, 
		"SEARCHMETHODID" SMALLINT NOT NULL, 
		"SEARCHKEY" VARCHAR(640) NOT NULL, 
		"SEARCHARGUMENT" VARCHAR(2700) NOT NULL, 
		"EXACT" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXEXTENSIONMETHODS" (
		"METHODNAME" VARCHAR(128) NOT NULL, 
		"METHODID" SMALLINT NOT NULL, 
		"IESCHEMA" VARCHAR(128) NOT NULL, 
		"IENAME" VARCHAR(128) NOT NULL, 
		"RTFUNCSCHEMA" VARCHAR(128) NOT NULL, 
		"RTFUNCNAME" VARCHAR(128) NOT NULL, 
		"RTSPECIFICNAME" VARCHAR(128) NOT NULL, 
		"CWFUNCSCHEMA" VARCHAR(128), 
		"CWFUNCNAME" VARCHAR(128), 
		"CWSPECIFICNAME" VARCHAR(128), 
		"REMARKS" VARCHAR(254)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXEXTENSIONPARMS" (
		"IESCHEMA" VARCHAR(128) NOT NULL, 
		"IENAME" VARCHAR(128) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"PARMNAME" VARCHAR(128) NOT NULL, 
		"TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"TYPENAME" VARCHAR(128) NOT NULL, 
		"LENGTH" INTEGER NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"PARMTYPE" CHAR(1) NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXEXTENSIONS" (
		"IESCHEMA" VARCHAR(128) NOT NULL, 
		"IENAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"KTFUNCSCHEMA" VARCHAR(128) NOT NULL, 
		"KTFUNCNAME" VARCHAR(128) NOT NULL, 
		"KTSPECIFICNAME" VARCHAR(128) NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"INDEX_DESC" BLOB(10485760) INLINE LENGTH 196 NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXOPTIONS" (
		"INDSCHEMA" VARCHAR(128) NOT NULL, 
		"INDNAME" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXPARTITIONS" (
		"INDSCHEMA" VARCHAR(128) NOT NULL, 
		"INDNAME" VARCHAR(128) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"IID" SMALLINT NOT NULL, 
		"INDPARTITIONTBSPACEID" INTEGER NOT NULL, 
		"INDPARTITIONOBJECTID" INTEGER NOT NULL, 
		"DATAPARTITIONID" INTEGER NOT NULL, 
		"INDCARD" BIGINT NOT NULL, 
		"NLEAF" BIGINT NOT NULL, 
		"NUM_EMPTY_LEAFS" BIGINT NOT NULL, 
		"NUMRIDS" BIGINT NOT NULL, 
		"NUMRIDS_DELETED" BIGINT NOT NULL, 
		"FULLKEYCARD" BIGINT NOT NULL, 
		"NLEVELS" SMALLINT NOT NULL, 
		"CLUSTERRATIO" SMALLINT NOT NULL, 
		"CLUSTERFACTOR" DOUBLE NOT NULL, 
		"FIRSTKEYCARD" BIGINT NOT NULL, 
		"FIRST2KEYCARD" BIGINT NOT NULL, 
		"FIRST3KEYCARD" BIGINT NOT NULL, 
		"FIRST4KEYCARD" BIGINT NOT NULL, 
		"AVGLEAFKEYSIZE" INTEGER NOT NULL, 
		"AVGNLEAFKEYSIZE" INTEGER NOT NULL, 
		"PCTFREE" SMALLINT NOT NULL, 
		"PAGE_FETCH_PAIRS" VARCHAR(520) NOT NULL, 
		"SEQUENTIAL_PAGES" BIGINT NOT NULL, 
		"DENSITY" INTEGER NOT NULL, 
		"AVERAGE_SEQUENCE_GAP" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_FETCH_GAP" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_SEQUENCE_FETCH_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_RANDOM_PAGES" DOUBLE NOT NULL, 
		"AVERAGE_RANDOM_FETCH_PAGES" DOUBLE NOT NULL, 
		"STATS_TIME" TIMESTAMP, 
		"COMPRESSION" CHAR(1) NOT NULL, 
		"PCTPAGESSAVED" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINDEXXMLPATTERNS" (
		"INDSCHEMA" VARCHAR(128) NOT NULL, 
		"INDNAME" VARCHAR(128) NOT NULL, 
		"PINDNAME" VARCHAR(128) NOT NULL, 
		"PINDID" SMALLINT NOT NULL, 
		"TYPEMODEL" CHAR(1) NOT NULL, 
		"DATATYPE" VARCHAR(128) NOT NULL, 
		"HASHED" CHAR(1) NOT NULL, 
		"LENGTH" SMALLINT NOT NULL, 
		"PATTERNID" SMALLINT NOT NULL, 
		"PATTERN" CLOB(2097152) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSINVALIDOBJECTS" (
		"OBJECTSCHEMA" VARCHAR(128) NOT NULL, 
		"OBJECTNAME" VARCHAR(128) NOT NULL, 
		"OBJECTMODULEID" INTEGER, 
		"OBJECTTYPE" CHAR(1) NOT NULL, 
		"SQLCODE" INTEGER, 
		"SQLSTATE" CHAR(5), 
		"SQLERRMC" VARCHAR(70), 
		"LINENUMBER" INTEGER, 
		"INVALIDATE_TIME" TIMESTAMP NOT NULL, 
		"LAST_REGEN_TIME" TIMESTAMP
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSJARCONTENTS" (
		"JARSCHEMA" VARCHAR(128) NOT NULL, 
		"JAR_ID" VARCHAR(128) NOT NULL, 
		"CLASS" VARCHAR(384) NOT NULL, 
		"CLASS_SOURCE" CLOB(10485760) INLINE LENGTH 196
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSJAROBJECTS" (
		"JARSCHEMA" VARCHAR(128) NOT NULL, 
		"JAR_ID" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"JAR_DATA" BLOB(104857600) INLINE LENGTH 196, 
		"ALTEREDTS" TIMESTAMP NOT NULL, 
		"CREATEDTS" TIMESTAMP NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSJOBS" (
		"JOBID" BIGINT NOT NULL, 
		"JOBTYPE" INTEGER NOT NULL, 
		"JOBVERSION" INTEGER NOT NULL, 
		"NUMSTAGES" INTEGER NOT NULL, 
		"STAGESYNC" CHAR (8) FOR BIT DATA NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"CREATE_DBPARTITIONNUM" SMALLINT NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"PRIORITY" INTEGER, 
		"STATE" CHAR(1), 
		"JOB_DESC" BLOB(4190000) INLINE LENGTH 164, 
		"OWNERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSKEYCOLUSE" (
		"CONSTNAME" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"COLNAME" VARCHAR(128) NOT NULL, 
		"COLSEQ" SMALLINT NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSLIBRARIES" (
		"LIBSCHEMA" VARCHAR(128) NOT NULL, 
		"LIBNAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"LIB_ID" INTEGER NOT NULL, 
		"LIBVERSION_COUNT" INTEGER NOT NULL, 
		"ACTIVE_VERSION" INTEGER NOT NULL, 
		"SYSTEM_REQUIRED" SMALLINT NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSLIBRARYAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"LIBSCHEMA" VARCHAR(128) NOT NULL, 
		"LIBNAME" VARCHAR(128) NOT NULL, 
		"USAGEAUTH" CHAR(1) NOT NULL, 
		"ALTERAUTH" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSLIBRARYBINDFILES" (
		"LIB_ID" INTEGER NOT NULL, 
		"LIBVERSION" INTEGER NOT NULL, 
		"PACKAGE_SCHEMA" VARCHAR(128) NOT NULL, 
		"PACKAGE_NAME" VARCHAR(128) NOT NULL, 
		"PACKAGE_VERSION" VARCHAR(64) NOT NULL, 
		"BINDFILE_PATH" VARCHAR(255) NOT NULL, 
		"BINDFILE_BODY" BLOB(10485760) INLINE LENGTH 196 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSLIBRARYVERSIONS" (
		"LIB_ID" INTEGER NOT NULL, 
		"LIBVERSION" INTEGER NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"VERSION_PATH" VARCHAR(255) NOT NULL, 
		"BINDFILES_COUNT" SMALLINT NOT NULL, 
		"VERSION_BODY" BLOB(20971520) INLINE LENGTH 196 NOT NULL, 
		"CHECKSUM" INTEGER NOT NULL, 
		"STALE" CHAR(1), 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSMODULEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTORROLEID" INTEGER, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"MODULEID" INTEGER NOT NULL, 
		"EXECUTEAUTH" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSMODULES" (
		"MODULESCHEMA" VARCHAR(128) NOT NULL, 
		"MODULENAME" VARCHAR(128) NOT NULL, 
		"MODULEID" INTEGER NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"OWNERTYPE" CHAR(1) NOT NULL, 
		"MODULETYPE" CHAR(1) NOT NULL, 
		"BASE_MODULESCHEMA" VARCHAR(128), 
		"BASE_MODULENAME" VARCHAR(128), 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"SOURCEHEADER" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"SOURCEBODY" CLOB(2097152) INLINE LENGTH 164 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSNAMEMAPPINGS" (
		"TYPE" CHAR(1) NOT NULL, 
		"LOGICAL_SCHEMA" VARCHAR(128) NOT NULL, 
		"LOGICAL_NAME" VARCHAR(128) NOT NULL, 
		"LOGICAL_COLNAME" VARCHAR(128), 
		"IMPL_SCHEMA" VARCHAR(128) NOT NULL, 
		"IMPL_NAME" VARCHAR(128) NOT NULL, 
		"IMPL_COLNAME" VARCHAR(128)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSNODEGROUPDEF" (
		"NGNAME" VARCHAR(128) NOT NULL, 
		"NODENUM" SMALLINT NOT NULL, 
		"IN_USE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSNODEGROUPS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"PMAP_ID" SMALLINT NOT NULL, 
		"REBALANCE_PMAP_ID" SMALLINT NOT NULL, 
		"CTIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"EXEC_INFO" BLOB(1048576) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPARTITIONMAPS" (
		"PMAP_ID" SMALLINT NOT NULL, 
		"PARTITIONMAP" BLOB(65536) INLINE LENGTH 116 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPASSTHRUAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SERVERNAME" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPLAN" (
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"BOUNDBY" VARCHAR(128) NOT NULL, 
		"VALID" CHAR(1) NOT NULL, 
		"UNIQUE_ID" CHAR (8) FOR BIT DATA NOT NULL, 
		"TOTALSECT" SMALLINT NOT NULL, 
		"FORMAT" CHAR(1) NOT NULL, 
		"SECT_INFO" BLOB(1048576) INLINE LENGTH 164 NOT NULL, 
		"HOST_VARS" BLOB(1048576) INLINE LENGTH 164, 
		"ISOLATION" CHAR(2), 
		"BLOCK" CHAR(1), 
		"STANDARDS_LEVEL" CHAR(1), 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92 NOT NULL, 
		"EXPLICIT_BIND_TIME" TIMESTAMP NOT NULL, 
		"LAST_BIND_TIME" TIMESTAMP NOT NULL, 
		"QUERYOPT" INTEGER NOT NULL, 
		"EXPLAIN_LEVEL" CHAR(1) NOT NULL, 
		"EXPLAIN_MODE" CHAR(1) NOT NULL, 
		"EXPLAIN_SNAPSHOT" CHAR(1) NOT NULL, 
		"SQLWARN" CHAR(1) NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"SQLRULES" CHAR(1) NOT NULL, 
		"SQLRULES_STRING" VARCHAR(254) NOT NULL, 
		"INSERT_BUF" CHAR(1) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"DEFAULT_SCHEMA" VARCHAR(128) NOT NULL, 
		"MULTINODE_PLANS" CHAR(1) NOT NULL, 
		"DEGREE" CHAR(5) NOT NULL, 
		"RDS_LEVEL" SMALLINT NOT NULL, 
		"SQLMATHWARN" CHAR(1) NOT NULL, 
		"INTRA_PARALLEL" CHAR(1) NOT NULL, 
		"VALIDATE" CHAR(1) NOT NULL, 
		"DYNAMICRULES" CHAR(1) NOT NULL, 
		"SQLERROR" CHAR(1) NOT NULL, 
		"REFRESHAGE" DECIMAL(20 , 6) NOT NULL, 
		"PKG_CREATE_TIME" TIMESTAMP NOT NULL, 
		"FEDERATED" CHAR(1) NOT NULL, 
		"TRANSFORMGROUP" VARCHAR(1024), 
		"TRF_GRP_PACKED_DESC" BLOB(2048) INLINE LENGTH 92, 
		"PKGVERSION" VARCHAR(64) NOT NULL, 
		"REOPTVAR" CHAR(1) NOT NULL, 
		"OS_PTR_SIZE" INTEGER NOT NULL, 
		"PACKED_DESC" BLOB(1048576) INLINE LENGTH 164, 
		"STATICREADONLY" CHAR(1) NOT NULL, 
		"FEDERATED_ASYNCHRONY" INTEGER NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"BOUNDBYTYPE" CHAR(1) NOT NULL, 
		"OPTPROFILESCHEMA" VARCHAR(128), 
		"OPTPROFILENAME" VARCHAR(128), 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL, 
		"CONCURRENTACCESSRESOLUTION" CHAR(1), 
		"PKGID" BIGINT NOT NULL, 
		"DBPARTITIONNUM" SMALLINT NOT NULL, 
		"APREUSE" CHAR(1) NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ANONBLOCK" CHAR(1) NOT NULL, 
		"EXTENDEDINDICATOR" CHAR(1) NOT NULL, 
		"LASTUSED" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPLANAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"CONTROLAUTH" CHAR(1) NOT NULL, 
		"BINDAUTH" CHAR(1) NOT NULL, 
		"EXECUTEAUTH" CHAR(1) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPLANDEP" (
		"BNAME" VARCHAR(128) NOT NULL, 
		"BCREATOR" VARCHAR(128) NOT NULL, 
		"BTYPE" CHAR(1) NOT NULL, 
		"DNAME" VARCHAR(128) NOT NULL, 
		"DCREATOR" VARCHAR(128) NOT NULL, 
		"BINDER" VARCHAR(128) NOT NULL, 
		"TABAUTH" SMALLINT, 
		"TABUSAGE" SMALLINT NOT NULL, 
		"COLUSAGE" BLOB(5120) INLINE LENGTH 92, 
		"DUNIQUE_ID" CHAR (8) FOR BIT DATA NOT NULL, 
		"BINDERTYPE" CHAR(1) NOT NULL, 
		"BMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSPREDICATESPECS" (
		"FUNCID" INTEGER NOT NULL, 
		"SPECID" SMALLINT NOT NULL, 
		"CONTEXTOP" CHAR(8) NOT NULL, 
		"CONTEXTEXP" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"FILTERTEXT" CLOB(2097152) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSRELS" (
		"CREATOR" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"RELNAME" VARCHAR(128) NOT NULL, 
		"REFTBNAME" VARCHAR(128) NOT NULL, 
		"REFTBCREATOR" VARCHAR(128) NOT NULL, 
		"COLCOUNT" SMALLINT NOT NULL, 
		"DELETERULE" CHAR(1) NOT NULL, 
		"UPDATERULE" CHAR(1) NOT NULL, 
		"TIMESTAMP" TIMESTAMP NOT NULL, 
		"FKCOLNAMES" VARCHAR(640) NOT NULL, 
		"PKCOLNAMES" VARCHAR(640) NOT NULL, 
		"REFKEYNAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROLEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTORROLEID" INTEGER, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"ROLENAME" VARCHAR(128) NOT NULL, 
		"ROLEID" INTEGER NOT NULL, 
		"ADMIN" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROLES" (
		"ROLENAME" VARCHAR(128) NOT NULL, 
		"ROLEID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"AUDITPOLICYID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SCHEMA" VARCHAR(128) NOT NULL, 
		"SPECIFICNAME" VARCHAR(128), 
		"TYPESCHEMA" VARCHAR(128), 
		"TYPENAME" VARCHAR(128), 
		"ROUTINETYPE" CHAR(1) NOT NULL, 
		"EXECUTEAUTH" CHAR(1) NOT NULL, 
		"GRANT_TIME" TIMESTAMP NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINEOPTIONS" (
		"ROUTINEID" INTEGER NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINEPARMOPTIONS" (
		"ROUTINEID" INTEGER NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINEPARMS" (
		"ROUTINENAME" VARCHAR(128) NOT NULL, 
		"ROUTINESCHEMA" VARCHAR(128) NOT NULL, 
		"SPECIFICNAME" VARCHAR(128) NOT NULL, 
		"ROWTYPE" CHAR(1) NOT NULL, 
		"ORDINAL" SMALLINT NOT NULL, 
		"TYPENAME" VARCHAR(128) NOT NULL, 
		"TYPESCHEMA" VARCHAR(128) NOT NULL, 
		"LENGTH" INTEGER NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"CAST_FUNCTION_ID" INTEGER, 
		"PARMNAME" VARCHAR(128), 
		"LOCATOR" CHAR(1) NOT NULL, 
		"TARGET_TYPESCHEMA" VARCHAR(128), 
		"TARGET_TYPENAME" VARCHAR(128), 
		"SCOPE_TABSCHEMA" VARCHAR(128), 
		"SCOPE_TABNAME" VARCHAR(128), 
		"TRANSFORM_GRPNAME" VARCHAR(128), 
		"ROUTINE_ID" INTEGER NOT NULL, 
		"ROUTINETYPE" CHAR(1) NOT NULL, 
		"TARGET_TYPEID" SMALLINT, 
		"TYPEID" SMALLINT, 
		"REMARKS" VARCHAR(254), 
		"COLLATIONID" CHAR (8) FOR BIT DATA, 
		"ROUTINEMODULEID" INTEGER, 
		"DEFAULT" CLOB(65536) INLINE LENGTH 116, 
		"TYPEMODULEID" INTEGER, 
		"TARGET_TYPEMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINEPROPERTIES" (
		"ROUTINE_ID" INTEGER NOT NULL, 
		"CLASS" VARCHAR(384), 
		"JAR_ID" VARCHAR(128), 
		"JARSCHEMA" VARCHAR(128), 
		"JAR_SIGNATURE" VARCHAR(2048)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSROUTINES" (
		"ROUTINENAME" VARCHAR(128) NOT NULL, 
		"ROUTINESCHEMA" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"SPECIFICNAME" VARCHAR(128) NOT NULL, 
		"PARM_SIGNATURE" VARCHAR (180) FOR BIT DATA NOT NULL, 
		"ROUTINE_ID" INTEGER NOT NULL, 
		"RETURN_TYPE" SMALLINT NOT NULL, 
		"ORIGIN" CHAR(1) NOT NULL, 
		"FUNCTION_TYPE" CHAR(1) NOT NULL, 
		"CREATEDTS" TIMESTAMP NOT NULL, 
		"PARM_COUNT" SMALLINT NOT NULL, 
		"DETERMINISTIC" CHAR(1) NOT NULL, 
		"EXTERNAL_ACTION" CHAR(1) NOT NULL, 
		"FENCED" CHAR(1) NOT NULL, 
		"NULL_CALL" CHAR(1) NOT NULL, 
		"CAST_FUNCTION" CHAR(1) NOT NULL, 
		"ASSIGN_FUNCTION" CHAR(1) NOT NULL, 
		"SCRATCHPAD" CHAR(1) NOT NULL, 
		"FINAL_CALL" CHAR(1) NOT NULL, 
		"LANGUAGE" CHAR(8) NOT NULL, 
		"IMPLEMENTATION" VARCHAR(762), 
		"SOURCESPECIFIC" VARCHAR(128), 
		"SOURCESCHEMA" VARCHAR(128), 
		"IOS_PER_INVOC" DOUBLE NOT NULL, 
		"INSTS_PER_INVOC" DOUBLE NOT NULL, 
		"IOS_PER_ARGBYTE" DOUBLE NOT NULL, 
		"INSTS_PER_ARGBYTE" DOUBLE NOT NULL, 
		"PERCENT_ARGBYTES" SMALLINT NOT NULL, 
		"INITIAL_IOS" DOUBLE NOT NULL, 
		"INITIAL_INSTS" DOUBLE NOT NULL, 
		"INTERNAL_PREC1" INTEGER NOT NULL, 
		"INTERNAL_PREC2" DOUBLE NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"INTERNAL_DESC" BLOB(20971520) INLINE LENGTH 196 NOT NULL, 
		"PARALLEL" CHAR(1) NOT NULL, 
		"SQL_DATA_ACCESS" CHAR(1) NOT NULL, 
		"DBINFO" CHAR(1) NOT NULL, 
		"RESULT_COLS" SMALLINT NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164, 
		"CARDINALITY" BIGINT NOT NULL, 
		"PARAMETER_STYLE" CHAR(8) NOT NULL, 
		"METHODIMPLEMENTED" CHAR(1) NOT NULL, 
		"METHODEFFECT" CHAR(2) NOT NULL, 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92, 
		"TYPE_PRESERVING" CHAR(1) NOT NULL, 
		"WITH_FUNC_ACCESS" CHAR(1) NOT NULL, 
		"SELECTIVITY" DOUBLE NOT NULL, 
		"OVERRIDDEN_METHODID" INTEGER, 
		"SUBJECT_TYPESCHEMA" VARCHAR(128), 
		"SUBJECT_TYPENAME" VARCHAR(128), 
		"QUALIFIER" VARCHAR(128) NOT NULL, 
		"SCRATCHPAD_LENGTH" SMALLINT NOT NULL, 
		"LIB_ID" INTEGER, 
		"SPEC_REG" CHAR(1) NOT NULL, 
		"FEDERATED" CHAR(1) NOT NULL, 
		"ALTEREDTS" TIMESTAMP NOT NULL, 
		"SOURCEROUTINEID" INTEGER, 
		"SUBJECT_TYPEID" SMALLINT, 
		"ROUTINETYPE" CHAR(1) NOT NULL, 
		"THREADSAFE" CHAR(1) NOT NULL, 
		"RESULT_SETS" SMALLINT NOT NULL, 
		"PROGRAM_TYPE" CHAR(1) NOT NULL, 
		"VALID" CHAR(1) NOT NULL, 
		"TEXT_BODY_OFFSET" INTEGER NOT NULL, 
		"COMMIT_ON_RETURN" CHAR(1) NOT NULL, 
		"NAMESPACE" CHAR(1) NOT NULL, 
		"METHODPROPERTY" CHAR(1) NOT NULL, 
		"NEWSAVEPOINTLEVEL" CHAR(1) NOT NULL, 
		"EXECUTION_CONTROL" CHAR(1) NOT NULL, 
		"DEBUG_MODE" CHAR(1) NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"ENCODING_SCHEME" CHAR(1) NOT NULL, 
		"LAST_REGEN_TIME" TIMESTAMP NOT NULL, 
		"INHERITLOCKREQUEST" CHAR(1) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL, 
		"ROUTINEMODULEID" INTEGER, 
		"PUBLISHED" CHAR(1) NOT NULL, 
		"AUTONOMOUS" CHAR(1) NOT NULL, 
		"DIALECT" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSCHEMAAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SCHEMANAME" VARCHAR(128) NOT NULL, 
		"CREATEINAUTH" CHAR(1) NOT NULL, 
		"DROPINAUTH" CHAR(1) NOT NULL, 
		"ALTERINAUTH" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSCHEMATA" (
		"NAME" VARCHAR(128) NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"OWNERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECTION" (
		"PLNAME" VARCHAR(128) NOT NULL, 
		"PLCREATOR" VARCHAR(128) NOT NULL, 
		"SECTNO" SMALLINT NOT NULL, 
		"SECTION" BLOB(10485760) INLINE LENGTH 196, 
		"VALID" CHAR(1) NOT NULL, 
		"UNIQUE_ID" CHAR (8) FOR BIT DATA NOT NULL, 
		"SECTION_INFO" BLOB(4190000) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYLABELACCESS" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SECLABELID" INTEGER NOT NULL, 
		"SECPOLICYID" INTEGER NOT NULL, 
		"ACCESSTYPE" CHAR(1) NOT NULL, 
		"GRANT_TIME" TIMESTAMP NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYLABELCOMPONENTELEMENTS" (
		"COMPID" INTEGER NOT NULL, 
		"ELEMENTVALUE" VARCHAR(32) NOT NULL, 
		"ELEMENTVALUEENCODING" CHAR (8) FOR BIT DATA NOT NULL, 
		"PARENTELEMENTVALUE" VARCHAR(32)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYLABELCOMPONENTS" (
		"COMPNAME" VARCHAR(128) NOT NULL, 
		"COMPID" INTEGER NOT NULL, 
		"COMPTYPE" CHAR(1) NOT NULL, 
		"NUMELEMENTS" INTEGER NOT NULL, 
		"ENCODINGINFO" VARCHAR (128) FOR BIT DATA, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYLABELS" (
		"SECLABELNAME" VARCHAR(128) NOT NULL, 
		"SECPOLICYID" INTEGER NOT NULL, 
		"SECLABELID" INTEGER NOT NULL, 
		"SECLABEL_INTERNAL" VARCHAR (128) FOR BIT DATA NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYPOLICIES" (
		"SECPOLICYNAME" VARCHAR(128) NOT NULL, 
		"SECPOLICYID" INTEGER NOT NULL, 
		"NUMSECLABELCOMP" INTEGER NOT NULL, 
		"RWSECLABELREL" CHAR(1) NOT NULL, 
		"NOTAUTHWRITESECLABEL" CHAR(1) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"USERAUTHS" CHAR(1) NOT NULL, 
		"GROUPAUTHS" CHAR(1) NOT NULL, 
		"ROLEAUTHS" CHAR(1) NOT NULL, 
		"PACKED_DESC" BLOB(65536) INLINE LENGTH 116
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYPOLICYCOMPONENTRULES" (
		"SECPOLICYID" INTEGER NOT NULL, 
		"COMPID" INTEGER NOT NULL, 
		"ORDINAL" INTEGER NOT NULL, 
		"READACCESSRULENAME" VARCHAR(128) NOT NULL, 
		"READACCESSRULETEXT" VARCHAR(512) NOT NULL, 
		"READACCESSRULE" CHAR (1) FOR BIT DATA NOT NULL, 
		"WRITEACCESSRULENAME" VARCHAR(128) NOT NULL, 
		"WRITEACCESSRULETEXT" VARCHAR(512) NOT NULL, 
		"WRITEACCESSRULE" CHAR (1) FOR BIT DATA NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSECURITYPOLICYEXEMPTIONS" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SECPOLICYID" INTEGER NOT NULL, 
		"ACCESSRULENAME" VARCHAR(128) NOT NULL, 
		"ACCESSTYPE" CHAR(1) NOT NULL, 
		"ORDINAL" INTEGER NOT NULL, 
		"EXEMPTION" CHAR (1) FOR BIT DATA NOT NULL, 
		"ACTIONALLOWED" CHAR(1) NOT NULL, 
		"GRANT_TIME" TIMESTAMP NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSEQUENCEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"SEQID" INTEGER NOT NULL, 
		"USAGEAUTH" CHAR(1) NOT NULL, 
		"ALTERAUTH" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSEQUENCES" (
		"LASTASSIGNEDVAL" DECIMAL(31 , 0), 
		"SEQID" INTEGER NOT NULL, 
		"SEQSCHEMA" VARCHAR(128) NOT NULL, 
		"SEQNAME" VARCHAR(128) NOT NULL, 
		"INCREMENT" DECIMAL(31 , 0), 
		"START" DECIMAL(31 , 0), 
		"MAXVALUE" DECIMAL(31 , 0), 
		"MINVALUE" DECIMAL(31 , 0), 
		"CYCLE" CHAR(1) NOT NULL, 
		"CACHE" INTEGER NOT NULL, 
		"ORDER" CHAR(1) NOT NULL, 
		"ORIGIN" CHAR(1) NOT NULL, 
		"SEQTYPE" CHAR(1) NOT NULL, 
		"DATATYPEID" INTEGER NOT NULL, 
		"SEQ_DESC" BLOB(65536) INLINE LENGTH 116, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"SOURCETYPEID" INTEGER NOT NULL, 
		"PRECISION" SMALLINT NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"OWNERTYPE" CHAR(1) NOT NULL, 
		"BASE_SEQSCHEMA" VARCHAR(128), 
		"BASE_SEQNAME" VARCHAR(128)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSERVEROPTIONS" (
		"WRAPNAME" VARCHAR(128), 
		"SERVERNAME" VARCHAR(128), 
		"SERVERTYPE" VARCHAR(30), 
		"SERVERVERSION" VARCHAR(18), 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL, 
		"SERVEROPTIONKEY" VARCHAR(18) NOT NULL, 
		"REMARKS" VARCHAR(254)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSERVERS" (
		"WRAPNAME" VARCHAR(128) NOT NULL, 
		"SERVERNAME" VARCHAR(128) NOT NULL, 
		"SERVERTYPE" VARCHAR(30), 
		"SERVERVERSION" VARCHAR(18), 
		"SERVER_DESC" BLOB(10485760) INLINE LENGTH 196, 
		"REMARKS" VARCHAR(254)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSERVICECLASSES" (
		"SERVICECLASSNAME" VARCHAR(128) NOT NULL, 
		"SERVICECLASSID" SMALLINT NOT NULL, 
		"PARENTID" SMALLINT NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"AGENTPRIORITY" SMALLINT NOT NULL, 
		"PREFETCHPRIORITY" CHAR(1) NOT NULL, 
		"INBOUNDCORRELATOR" VARCHAR(128), 
		"OUTBOUNDCORRELATOR" VARCHAR(128), 
		"COLLECTAGGACTDATA" CHAR(1) NOT NULL, 
		"COLLECTAGGREQDATA" CHAR(1) NOT NULL, 
		"COLLECTACTDATA" CHAR(1) NOT NULL, 
		"COLLECTACTPARTITION" CHAR(1) NOT NULL, 
		"SERVICECLASS_DESC" BLOB(1048576) INLINE LENGTH 164, 
		"BUFFERPOOLPRIORITY" CHAR(1) NOT NULL, 
		"COLLECTREQMETRICS" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSTMT" (
		"PLNAME" VARCHAR(128) NOT NULL, 
		"PLCREATOR" VARCHAR(128) NOT NULL, 
		"STMTNO" INTEGER NOT NULL, 
		"SECTNO" SMALLINT NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"UNIQUE_ID" CHAR (8) FOR BIT DATA NOT NULL, 
		"HOST_VARS" BLOB(4190000) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSSURROGATEAUTHIDS" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"TRUSTEDID" VARCHAR(128) NOT NULL, 
		"TRUSTEDIDTYPE" CHAR(1) NOT NULL, 
		"SURROGATEAUTHID" VARCHAR(128) NOT NULL, 
		"SURROGATEAUTHIDTYPE" CHAR(1) NOT NULL, 
		"AUTHENTICATE" CHAR(1) NOT NULL, 
		"CONTEXTROLE" VARCHAR(128), 
		"GRANT_TIME" TIMESTAMP NOT NULL, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTABAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"TCREATOR" VARCHAR(128) NOT NULL, 
		"TTNAME" VARCHAR(128) NOT NULL, 
		"TABAUTH" SMALLINT NOT NULL, 
		"CONTROLAUTH" CHAR(1) NOT NULL, 
		"ALTERAUTH" CHAR(1) NOT NULL, 
		"DELETEAUTH" CHAR(1) NOT NULL, 
		"INDEXAUTH" CHAR(1) NOT NULL, 
		"INSERTAUTH" CHAR(1) NOT NULL, 
		"SELECTAUTH" CHAR(1) NOT NULL, 
		"UPDATEAUTH" CHAR(1) NOT NULL, 
		"REFAUTH" CHAR(1) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTABCONST" (
		"NAME" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"CONSTRAINTYP" CHAR(1) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"ENFORCED" CHAR(1) NOT NULL, 
		"CHECKEXISTINGDATA" CHAR(1) NOT NULL, 
		"ENABLEQUERYOPT" CHAR(1) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTABLES" (
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"TYPE" CHAR(1) NOT NULL, 
		"CTIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"PACKED_DESC" BLOB(133169152) INLINE LENGTH 196, 
		"VIEW_DESC" BLOB(4190000) INLINE LENGTH 164, 
		"COLCOUNT" SMALLINT NOT NULL, 
		"FID" SMALLINT NOT NULL, 
		"TID" SMALLINT NOT NULL, 
		"CARD" BIGINT NOT NULL, 
		"NPAGES" BIGINT NOT NULL, 
		"FPAGES" BIGINT NOT NULL, 
		"OVERFLOW" BIGINT NOT NULL, 
		"PARENTS" SMALLINT, 
		"CHILDREN" SMALLINT, 
		"SELFREFS" SMALLINT, 
		"KEYCOLUMNS" SMALLINT, 
		"KEYOBID" SMALLINT, 
		"REL_DESC" BLOB(262144) INLINE LENGTH 140, 
		"BASE_NAME" VARCHAR(128), 
		"BASE_SCHEMA" VARCHAR(128), 
		"TBSPACE" VARCHAR(128), 
		"INDEX_TBSPACE" VARCHAR(128), 
		"LONG_TBSPACE" VARCHAR(128), 
		"KEYUNIQUE" SMALLINT NOT NULL, 
		"CHECKCOUNT" SMALLINT NOT NULL, 
		"CHECK_DESC" BLOB(131072) INLINE LENGTH 140, 
		"STATS_TIME" TIMESTAMP, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"TRIG_DESC" BLOB(3145728) INLINE LENGTH 164, 
		"DATA_CAPTURE" CHAR(1) NOT NULL, 
		"STATUS" CHAR(1) NOT NULL, 
		"CONST_CHECKED" CHAR(32) NOT NULL, 
		"PMAP_ID" SMALLINT, 
		"ENCODING_SCHEME" CHAR(1) NOT NULL, 
		"PCTFREE" SMALLINT NOT NULL, 
		"ROWTYPESCHEMA" VARCHAR(128), 
		"ROWTYPENAME" VARCHAR(128), 
		"APPEND_MODE" CHAR(1) NOT NULL, 
		"PARTITION_MODE" CHAR(1) NOT NULL, 
		"REFRESH" CHAR(1) NOT NULL, 
		"REFRESH_TIME" TIMESTAMP, 
		"LOCKSIZE" CHAR(1) NOT NULL, 
		"VOLATILE" CHAR(1) NOT NULL, 
		"REMOTE_DESC" BLOB(10485760) INLINE LENGTH 196, 
		"CLUSTERED" CHAR(1), 
		"AST_DESC" BLOB(535822336) INLINE LENGTH 220, 
		"DROPRULE" CHAR(1) NOT NULL, 
		"LOGINDEXBUILD" CHAR(1) NOT NULL, 
		"PROPERTY" VARCHAR(32) NOT NULL, 
		"STATISTICS_PROFILE" CLOB(10485760) INLINE LENGTH 196, 
		"COMPRESSION" CHAR(1) NOT NULL, 
		"ACCESS_MODE" CHAR(1) NOT NULL, 
		"ACTIVE_BLOCKS" BIGINT NOT NULL, 
		"MAXFREESPACESEARCH" SMALLINT NOT NULL, 
		"AVGCOMPRESSEDROWSIZE" SMALLINT NOT NULL, 
		"AVGROWCOMPRESSIONRATIO" REAL NOT NULL, 
		"AVGROWSIZE" SMALLINT NOT NULL, 
		"PCTROWSCOMPRESSED" REAL NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"PCTPAGESSAVED" SMALLINT NOT NULL, 
		"LAST_REGEN_TIME" TIMESTAMP, 
		"SECPOLICYID" INTEGER NOT NULL, 
		"PROTECTIONGRANULARITY" CHAR(1) NOT NULL, 
		"INVALIDATE_TIME" TIMESTAMP NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"AUDITPOLICYID" INTEGER, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL, 
		"ONCOMMIT" CHAR(1) NOT NULL, 
		"ONROLLBACK" CHAR(1) NOT NULL, 
		"LOGGED" CHAR(1) NOT NULL, 
		"LASTUSED" DATE NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTABLESPACES" (
		"TBSPACE" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"TBSPACEID" INTEGER NOT NULL, 
		"TBSPACETYPE" CHAR(1) NOT NULL, 
		"DATATYPE" CHAR(1) NOT NULL, 
		"EXTENTSIZE" INTEGER NOT NULL, 
		"PREFETCHSIZE" INTEGER NOT NULL, 
		"OVERHEAD" DOUBLE NOT NULL, 
		"TRANSFERRATE" DOUBLE NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"NGNAME" VARCHAR(128) NOT NULL, 
		"BUFFERPOOLID" INTEGER NOT NULL, 
		"PAGESIZE" INTEGER NOT NULL, 
		"DROP_RECOVERY" CHAR(1) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"DATAPRIORITY" CHAR(1) NOT NULL, 
		"WRITEOVERHEAD" DOUBLE, 
		"WRITETRANSFERRATE" DOUBLE
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTABOPTIONS" (
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" CLOB(32768) INLINE LENGTH 116 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTASKS" (
		"JOBID" BIGINT NOT NULL, 
		"DBPARTITIONNUM" SMALLINT NOT NULL, 
		"STAGE" INTEGER NOT NULL, 
		"TASKID" BIGINT NOT NULL, 
		"STATE" INTEGER NOT NULL, 
		"TASKTYPE" INTEGER NOT NULL, 
		"TASKVERSION" INTEGER NOT NULL, 
		"PRIORITY" INTEGER, 
		"OBJECTTYPE" INTEGER, 
		"TBSPACEID" INTEGER, 
		"OBJECTID" INTEGER, 
		"INTERNALID" INTEGER, 
		"TASK_DESC" BLOB(4190000) INLINE LENGTH 164, 
		"CREATE_TIME" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTBSPACEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"TBSPACEID" INTEGER NOT NULL, 
		"USEAUTH" CHAR(1) NOT NULL, 
		"TBSPACE" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTHRESHOLDS" (
		"THRESHOLDNAME" VARCHAR(128) NOT NULL, 
		"THRESHOLDID" INTEGER NOT NULL, 
		"ORIGIN" CHAR(1) NOT NULL, 
		"THRESHOLDCLASS" CHAR(1) NOT NULL, 
		"THRESHOLDPREDICATE" VARCHAR(15) NOT NULL, 
		"THRESHOLDPREDICATEID" SMALLINT NOT NULL, 
		"DOMAIN" CHAR(2) NOT NULL, 
		"DOMAINID" INTEGER NOT NULL, 
		"ENFORCEMENT" CHAR(1) NOT NULL, 
		"QUEUING" CHAR(1) NOT NULL, 
		"MAXVALUE" BIGINT NOT NULL, 
		"QUEUESIZE" INTEGER NOT NULL, 
		"COLLECTACTDATA" CHAR(1) NOT NULL, 
		"COLLECTACTPARTITION" CHAR(1) NOT NULL, 
		"EXECUTION" CHAR(1) NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"THRESHOLD_DESC" BLOB(8192) INLINE LENGTH 92, 
		"REMAPSCID" SMALLINT NOT NULL, 
		"VIOLATIONRECORDLOGGED" CHAR(1) NOT NULL, 
		"CHECKINTERVAL" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTRANSFORMS" (
		"TYPEID" SMALLINT NOT NULL, 
		"GROUPNAME" VARCHAR(128) NOT NULL, 
		"FROMSQL_FUNCID" INTEGER, 
		"TOSQL_FUNCID" INTEGER, 
		"FROMSQL_FORMAT" CHAR(1) NOT NULL, 
		"TOSQL_FORMAT" CHAR(1) NOT NULL, 
		"FROMSQL_LENGTH" INTEGER NOT NULL, 
		"ORIGIN" CHAR(1) NOT NULL, 
		"REMARKS" VARCHAR(254)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTRIGGERS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"SCHEMA" VARCHAR(128) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"TBNAME" VARCHAR(128) NOT NULL, 
		"TBCREATOR" VARCHAR(128) NOT NULL, 
		"TRIGTIME" CHAR(1) NOT NULL, 
		"TRIGEVENT" CHAR(1) NOT NULL, 
		"GRANULARITY" CHAR(1) NOT NULL, 
		"VALID" CHAR(1) NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92 NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"QUALIFIER" VARCHAR(128) NOT NULL, 
		"LAST_REGEN_TIME" TIMESTAMP NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTUNINGINFO" (
		"TUNINGINFONAME" VARCHAR(128) NOT NULL, 
		"TUNINGVALUE" VARCHAR (2048) FOR BIT DATA
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSTYPEMAPPINGS" (
		"TYPE_MAPPING" VARCHAR(18) NOT NULL, 
		"TYPESCHEMA" VARCHAR(128), 
		"TYPENAME" VARCHAR(128) NOT NULL, 
		"TYPEID" SMALLINT NOT NULL, 
		"SOURCETYPEID" SMALLINT NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"UPPER_LEN" INTEGER, 
		"UPPER_SCALE" SMALLINT, 
		"BIT_DATA" CHAR(1), 
		"WRAPNAME" VARCHAR(128), 
		"SERVERNAME" VARCHAR(128), 
		"SERVERTYPE" VARCHAR(30), 
		"SERVERVERSION" VARCHAR(18), 
		"REMOTE_TYPESCHEMA" VARCHAR(128), 
		"REMOTE_TYPENAME" VARCHAR(128) NOT NULL, 
		"REMOTE_META_TYPE" CHAR(1), 
		"REMOTE_LOWER_LEN" INTEGER, 
		"REMOTE_UPPER_LEN" INTEGER, 
		"REMOTE_LOWER_SCALE" SMALLINT, 
		"REMOTE_UPPER_SCALE" SMALLINT, 
		"REMOTE_S_OPR_P" CHAR(2), 
		"REMOTE_BIT_DATA" CHAR(1), 
		"USER_DEFINED" CHAR(1) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"REMARKS" VARCHAR(254), 
		"MAPPINGDIRECTION" CHAR(1) NOT NULL, 
		"LOWER_LEN" INTEGER, 
		"LOWER_SCALE" SMALLINT, 
		"S_OPR_P" CHAR(2), 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSUSERAUTH" (
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"TABSCHEMA" VARCHAR(128) NOT NULL, 
		"TABNAME" VARCHAR(128) NOT NULL, 
		"AUTH_DESC" BLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"GRANTEEROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSUSEROPTIONS" (
		"SERVERNAME" VARCHAR(128) NOT NULL, 
		"AUTHID" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL, 
		"AUTHIDTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSVARIABLEAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTORROLEID" INTEGER, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"VARID" INTEGER NOT NULL, 
		"READAUTH" CHAR(1) NOT NULL, 
		"WRITEAUTH" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSVARIABLES" (
		"VARSCHEMA" VARCHAR(128) NOT NULL, 
		"VARNAME" VARCHAR(128) NOT NULL, 
		"VARID" INTEGER NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"OWNERTYPE" CHAR(1) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"LAST_REGEN_TIME" TIMESTAMP NOT NULL, 
		"TYPEID" SMALLINT NOT NULL, 
		"LENGTH" INTEGER NOT NULL, 
		"SCALE" SMALLINT NOT NULL, 
		"CODEPAGE" SMALLINT NOT NULL, 
		"SCOPE" CHAR(1) NOT NULL, 
		"DEFAULT" CLOB(65536) INLINE LENGTH 116, 
		"QUALIFIER" VARCHAR(128), 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92, 
		"VAR_DESC" BLOB(131072) INLINE LENGTH 140 NOT NULL, 
		"COLLATIONID" CHAR (8) FOR BIT DATA NOT NULL, 
		"COLLATIONID_ORDERBY" CHAR (8) FOR BIT DATA NOT NULL, 
		"VARMODULEID" INTEGER, 
		"PUBLISHED" CHAR(1) NOT NULL, 
		"VALID" CHAR(1) NOT NULL, 
		"READONLY" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSVERSIONS" (
		"VERSIONNUMBER" INTEGER NOT NULL, 
		"VERSION_TIMESTAMP" TIMESTAMP NOT NULL, 
		"AUTHID" VARCHAR(128) NOT NULL, 
		"VERSIONBUILDLEVEL" VARCHAR(30)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSVIEWDEP" (
		"BNAME" VARCHAR(128) NOT NULL, 
		"BCREATOR" VARCHAR(128) NOT NULL, 
		"BTYPE" CHAR(1) NOT NULL, 
		"DNAME" VARCHAR(128) NOT NULL, 
		"DCREATOR" VARCHAR(128) NOT NULL, 
		"VCAUTHID" VARCHAR(128) NOT NULL, 
		"TABAUTH" SMALLINT, 
		"DTYPE" CHAR(1) NOT NULL, 
		"OUTER_FROM" CHAR(1) NOT NULL, 
		"VCAUTHIDTYPE" CHAR(1) NOT NULL, 
		"BMODULEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSVIEWS" (
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATOR" VARCHAR(128) NOT NULL, 
		"CHECK" CHAR(1) NOT NULL, 
		"TEXT" CLOB(2097152) INLINE LENGTH 164 NOT NULL, 
		"FUNC_PATH" CLOB(2048) INLINE LENGTH 92 NOT NULL, 
		"VALID" CHAR(1) NOT NULL, 
		"READONLY" CHAR(1) NOT NULL, 
		"DEFINER" VARCHAR(128) NOT NULL, 
		"QUALIFIER" VARCHAR(128) NOT NULL, 
		"DEFINERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKACTIONS" (
		"ACTIONNAME" VARCHAR(128) NOT NULL, 
		"ACTIONID" INTEGER NOT NULL, 
		"ACTIONSETID" INTEGER NOT NULL, 
		"WORKCLASSID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"ACTIONTYPE" CHAR(1) NOT NULL, 
		"REFOBJECTID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKACTIONSETS" (
		"ACTIONSETNAME" VARCHAR(128) NOT NULL, 
		"ACTIONSETID" INTEGER NOT NULL, 
		"WORKCLASSSETID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"OBJECTTYPE" CHAR(1) NOT NULL, 
		"OBJECTID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKCLASSES" (
		"WORKCLASSNAME" VARCHAR(128) NOT NULL, 
		"WORKCLASSID" INTEGER NOT NULL, 
		"WORKCLASSSETID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"WORKTYPE" SMALLINT NOT NULL, 
		"RANGEUNITS" CHAR(1) NOT NULL, 
		"FROMVALUE" DOUBLE, 
		"TOVALUE" DOUBLE, 
		"ROUTINESCHEMA" VARCHAR(128), 
		"EVALUATIONORDER" SMALLINT NOT NULL, 
		"WORKCLASS_DESC" BLOB(8192) INLINE LENGTH 92, 
		"INITIALSQLDATAPRIORITY" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKCLASSSETS" (
		"WORKCLASSSETNAME" VARCHAR(128) NOT NULL, 
		"WORKCLASSSETID" INTEGER NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKLOADAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTORROLEID" INTEGER, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"WORKLOADID" INTEGER NOT NULL, 
		"USAGEAUTH" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKLOADCONNATTR" (
		"WORKLOADID" INTEGER NOT NULL, 
		"CONNATTRID" SMALLINT NOT NULL, 
		"CONNATTRVALUE" VARCHAR(1000) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWORKLOADS" (
		"WORKLOADNAME" VARCHAR(128) NOT NULL, 
		"WORKLOADID" INTEGER NOT NULL, 
		"EVALUATIONORDER" SMALLINT NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"ENABLED" CHAR(1) NOT NULL, 
		"ALLOWACCESS" CHAR(1) NOT NULL, 
		"SERVICECLASSID" SMALLINT NOT NULL, 
		"COLLECTAGGACTDATA" CHAR(1) NOT NULL, 
		"COLLECTACTDATA" CHAR(1) NOT NULL, 
		"COLLECTACTPARTITION" CHAR(1) NOT NULL, 
		"EXTERNALNAME" VARCHAR(128), 
		"WORKLOAD_DESC" BLOB(8192) INLINE LENGTH 92, 
		"COLLECTDEADLOCK" CHAR(1) NOT NULL, 
		"COLLECTLOCKTIMEOUT" CHAR(1) NOT NULL, 
		"COLLECTLOCKWAIT" CHAR(1) NOT NULL, 
		"LOCKWAITVALUE" INTEGER NOT NULL, 
		"COLLECTACTMETRICS" CHAR(1) NOT NULL, 
		"COLLECTUOWDATA" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWRAPOPTIONS" (
		"WRAPNAME" VARCHAR(128) NOT NULL, 
		"OPTION" VARCHAR(128) NOT NULL, 
		"SETTING" VARCHAR(2048) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSWRAPPERS" (
		"WRAPNAME" VARCHAR(128) NOT NULL, 
		"WRAPTYPE" CHAR(1) NOT NULL, 
		"WRAPVERSION" INTEGER NOT NULL, 
		"LIBRARY" VARCHAR(255) NOT NULL, 
		"REMARKS" VARCHAR(254)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXDBMAPGRAPHS" (
		"XSROBJECTID" BIGINT NOT NULL, 
		"SCHEMAGRAPHID" INTEGER NOT NULL, 
		"NAMESPACEID" INTEGER NOT NULL, 
		"ROOTELEMENTID" INTEGER NOT NULL, 
		"SCHEMAGRAPH" BLOB(10485760) INLINE LENGTH 196 NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXDBMAPSHREDTREES" (
		"XSROBJECTID" BIGINT NOT NULL, 
		"SCHEMAGRAPHID" INTEGER NOT NULL, 
		"SHREDTREEID" INTEGER NOT NULL, 
		"SHREDTREE" BLOB(10485760) INLINE LENGTH 196 NOT NULL, 
		"MAPPINGDESCRIPTION" CLOB(1048576) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXMLPATHS" (
		"PATHID" INTEGER NOT NULL, 
		"PATHTYPE" CHAR (1) FOR BIT DATA NOT NULL, 
		"PATH" VARCHAR (1000) FOR BIT DATA NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXMLSTRINGS" (
		"STRINGID" INTEGER NOT NULL, 
		"STRING" VARCHAR (1001) FOR BIT DATA NOT NULL, 
		"IS_TEMPORARY" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXSROBJECTAUTH" (
		"GRANTOR" VARCHAR(128) NOT NULL, 
		"GRANTEE" VARCHAR(128) NOT NULL, 
		"GRANTEETYPE" CHAR(1) NOT NULL, 
		"XSROBJECTID" BIGINT NOT NULL, 
		"USAGEAUTH" CHAR(1) NOT NULL, 
		"GRANTORTYPE" CHAR(1) NOT NULL, 
		"GRANTEEROLEID" INTEGER, 
		"GRANTORROLEID" INTEGER
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXSROBJECTCOMPONENTS" (
		"XSRCOMPONENTID" BIGINT NOT NULL, 
		"TARGETNAMESPACEID" INTEGER NOT NULL, 
		"SCHEMALOCATIONID" INTEGER NOT NULL, 
		"VERSIONID" INTEGER NOT NULL, 
		"COMPONENT" BLOB(31457280) INLINE LENGTH 196 NOT NULL, 
		"DIGEST" CHAR (16) FOR BIT DATA NOT NULL, 
		"PROPERTIES" BLOB(4190000) INLINE LENGTH 164, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"STATUS" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXSROBJECTHIERARCHIES" (
		"XSROBJECTID" BIGINT NOT NULL, 
		"XSRCOMPONENTID" BIGINT NOT NULL, 
		"HTYPE" CHAR(1) NOT NULL, 
		"TARGETNAMESPACEID" INTEGER NOT NULL, 
		"SCHEMALOCATIONID" INTEGER NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSIBM"."SYSXSROBJECTS" (
		"XSROBJECTID" BIGINT NOT NULL, 
		"XSROBJECTSCHEMA" VARCHAR(128) NOT NULL, 
		"XSROBJECTNAME" VARCHAR(128) NOT NULL, 
		"TARGETNAMESPACEID" INTEGER NOT NULL, 
		"SCHEMALOCATIONID" INTEGER NOT NULL, 
		"VERSIONID" INTEGER NOT NULL, 
		"OBJECTINFO" XML, 
		"GRAMMAR" BLOB(133169152) INLINE LENGTH 196, 
		"PROPERTIES" BLOB(4190000) INLINE LENGTH 164, 
		"OBJECTTYPE" CHAR(1) NOT NULL, 
		"OWNER" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"ALTER_TIME" TIMESTAMP NOT NULL, 
		"STATUS" CHAR(1) NOT NULL, 
		"DECOMPOSITION" CHAR(1) NOT NULL, 
		"DECOMPOSITION_VERSION" VARCHAR(20), 
		"OWNERTYPE" CHAR(1) NOT NULL
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSTOOLS"."HMON_ATM_INFO" (
		"SCHEMA" VARCHAR(128) NOT NULL, 
		"NAME" VARCHAR(128) NOT NULL, 
		"CREATE_TIME" TIMESTAMP NOT NULL, 
		"STATS_FLAG" CHAR(1) NOT NULL DEFAULT 'N', 
		"STATS_LOCK" CHAR(1) NOT NULL DEFAULT 'N', 
		"STATS_OPTS" INTEGER NOT NULL DEFAULT 0, 
		"LAST_WAIT" INTEGER NOT NULL DEFAULT 4, 
		"TO_WAIT" INTEGER NOT NULL DEFAULT 1, 
		"SIGNAL" CHAR(1) NOT NULL DEFAULT 'N', 
		"LEO_TAB" CHAR(1) NOT NULL DEFAULT 'N', 
		"EXEC_COUNT" BIGINT NOT NULL DEFAULT 0, 
		"STATS_STATE" SMALLINT NOT NULL DEFAULT 0, 
		"STATS_NOTIFY" CHAR(1) NOT NULL DEFAULT 'N', 
		"STATS_DETAIL" VARCHAR(200), 
		"STATS_HISTORY" VARCHAR (200) FOR BIT DATA, 
		"STATS_TIME" TIMESTAMP, 
		"REORG_FLAG" CHAR(1) NOT NULL DEFAULT 'N', 
		"REORG_LOCK" CHAR(1) NOT NULL DEFAULT 'N', 
		"REORG_STATE" SMALLINT NOT NULL DEFAULT 0, 
		"REORG_TIME" TIMESTAMP, 
		"REORG_NOTIFY" CHAR(1) NOT NULL DEFAULT 'N', 
		"REORG_DETAIL" VARCHAR(200), 
		"REORG_HISTORY" VARCHAR (200) FOR BIT DATA, 
		"REORG_AVG_RUNTIME" INTEGER, 
		"REORG_INDEX_SCHEMA" VARCHAR(128), 
		"REORG_INDEX_NAME" VARCHAR(128), 
		"REORG_INDEX_ONLINE" CHAR(1)
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSTOOLS"."HMON_COLLECTION" (
		"HI_ID" BIGINT NOT NULL, 
		"OBJ_NAME1" VARCHAR(128) NOT NULL, 
		"OBJ_NAME2" VARCHAR(128) NOT NULL DEFAULT '', 
		"OBJ_NAME3" VARCHAR(128) NOT NULL DEFAULT '', 
		"OBJ_DETAIL" VARCHAR(512), 
		"OBJ_STATE" INTEGER NOT NULL, 
		"OBJ_REFRESH_TIME" TIMESTAMP NOT NULL, 
		"NOTIFY" CHAR(1) NOT NULL DEFAULT 'N', 
		"HISTORY" VARCHAR (200) FOR BIT DATA
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE TABLE "SYSTOOLS"."POLICY" (
		"MED" VARCHAR(128) NOT NULL, 
		"DECISION" VARCHAR(128) NOT NULL, 
		"NAME" VARCHAR(128) NOT NULL, 
		"UPDATE_TIME" TIMESTAMP NOT NULL, 
		"POLICY" BLOB(2097152) INLINE LENGTH 164
	)
	DATA CAPTURE NONE 
	COMPRESS NO;

CREATE INDEX "AJAY"."CUST_NAME_XMLIDX"
	ON "AJAY"."CUSTOMER"
	("INFO"		ASC) GENERATE KEY USING XMLPATTERN '/customerinfo/name' AS SQL VARCHAR (50) IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."CUST_PHONES_XMLIDX"
	ON "AJAY"."CUSTOMER"
	("INFO"		ASC) GENERATE KEY USING XMLPATTERN '/customerinfo/phone' AS SQL VARCHAR (25) IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."CUST_PHONET_XMLIDX"
	ON "AJAY"."CUSTOMER"
	("INFO"		ASC) GENERATE KEY USING XMLPATTERN '/customerinfo/phone/@type' AS SQL VARCHAR (25) IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."PO_CID_XMLIDX"
	ON "AJAY"."PURCHASEORDER"
	("PORDER"		ASC) GENERATE KEY USING XMLPATTERN '/PurchaseOrder/@Cid' AS SQL DOUBLE IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."PO_PRODS_XMLIDX"
	ON "AJAY"."PURCHASEORDER"
	("PORDER"		ASC) GENERATE KEY USING XMLPATTERN '/PurchaseOrder/itemlist/item/product/@pid' AS SQL DOUBLE IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."PO_ZIP_XMLIDX"
	ON "AJAY"."PURCHASEORDER"
	("PORDER"		ASC) GENERATE KEY USING XMLPATTERN '/PurchaseOrder/customerAdr/addr/pcode-zip' AS SQL VARCHAR (16) IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."PROD_DETAIL_XMLIDX"
	ON "AJAY"."PRODUCT"
	("DESCRIPTION"		ASC) GENERATE KEY USING XMLPATTERN '/product/description/detail' AS SQL VARCHAR HASHED IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."PROD_NAME_XMLIDX"
	ON "AJAY"."PRODUCT"
	("DESCRIPTION"		ASC) GENERATE KEY USING XMLPATTERN '/product/description/name' AS SQL VARCHAR (128) IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."XDEPT2"
	ON "AJAY"."DEPARTMENT"
	("MGRNO"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."XDEPT3"
	ON "AJAY"."DEPARTMENT"
	("ADMRDEPT"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."XEMP2"
	ON "AJAY"."EMPLOYEE"
	("WORKDEPT"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "AJAY"."XPROJ2"
	ON "AJAY"."PROJECT"
	("RESPEMP"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I01"
	ON "DB2ADMIN"."PILOT"
	("CREW_ID"		ASC, 
	  "CMID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I02"
	ON "DB2ADMIN"."ATTENDENT"
	("CREW_ID"		ASC, 
	  "CMID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I03"
	ON "DB2ADMIN"."SEATS"
	("ATID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I04"
	ON "DB2ADMIN"."HISTORY"
	("TENANTID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I05"
	ON "DB2ADMIN"."AREA"
	("APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I06"
	ON "DB2ADMIN"."AREA_RENTED_BY"
	("AREAID"		ASC, 
	  "TENANTID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I07"
	ON "DB2ADMIN"."CHECKINCOUNTER"
	("APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I08"
	ON "DB2ADMIN"."LUGGAGE_TAGGED_BY"
	("APCODE"		ASC, 
	  "LUGGAGEID"		ASC, 
	  "CHKINCOUNTERNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I09"
	ON "DB2ADMIN"."PERSONNEL_ASSIGNED_TO_CHECKIN"
	("CHPID"		ASC, 
	  "CHKINCOUNTERNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I10"
	ON "DB2ADMIN"."M_WORKS_IN"
	("MPID"		ASC, 
	  "APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I11"
	ON "DB2ADMIN"."ROUTE"
	("APCODE_SRC"		ASC, 
	  "APCODE_DST"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I12"
	ON "DB2ADMIN"."FLIGHTSEGMENT"
	("ROUTEID"		ASC, 
	  "CREW_ID"		ASC, 
	  "APID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I13"
	ON "DB2ADMIN"."TECHNICAL_NOTE"
	("MPID"		ASC, 
	  "CODE"		ASC, 
	  "FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I14"
	ON "DB2ADMIN"."CATERINGFACILITY"
	("APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I15"
	ON "DB2ADMIN"."ASSIGNED_TO_CATERING_FACILITY"
	("KSID"		ASC, 
	  "CFID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I16"
	ON "DB2ADMIN"."PARKINGSLOTLOG"
	("FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I17"
	ON "DB2ADMIN"."RUNWAYLOG"
	("FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I18"
	ON "DB2ADMIN"."AIRLINE"
	("ABB_TEXT"		ASC, 
	  "ADID"		ASC, 
	  "CFID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I19"
	ON "DB2ADMIN"."AIRPLANE"
	("ATID"		ASC, 
	  "ALID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I20"
	ON "DB2ADMIN"."SCHEDULEDMAINTENANCE"
	("APID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I21"
	ON "DB2ADMIN"."BOARDINGPASS"
	("PASSENGERID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I22"
	ON "DB2ADMIN"."ATTACHES_WITH"
	("LUGGAGEID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I23"
	ON "DB2ADMIN"."CONTACTS"
	("AGENTID"		ASC, 
	  "CUSTOMERID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I24"
	ON "DB2ADMIN"."DELAY"
	("FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I25"
	ON "DB2ADMIN"."FARE"
	("FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I26"
	ON "DB2ADMIN"."FLIGHT_ORDERS"
	("FLIGHTNR"		ASC, 
	  "CATID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I27"
	ON "DB2ADMIN"."SEGMENTTICKET"
	("FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I28"
	ON "DB2ADMIN"."TICKET"
	("CUSTOMERID"		ASC, 
	  "FLIGHTID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I29"
	ON "DB2ADMIN"."PARKINGSLOT"
	("APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I30"
	ON "DB2ADMIN"."CHECKIN"
	("CHKINCOUNTERNR"		ASC, 
	  "PASSENGERID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I31"
	ON "DB2ADMIN"."RUNWAY"
	("FCONTROLLERID"		ASC, 
	  "APCODE"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I32"
	ON "DB2ADMIN"."TRANSACTIONS"
	("AGENTID"		ASC, 
	  "FLIGHTID"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I33"
	ON "DB2ADMIN"."RUNWAY_USED_BY"
	("APCODE"		ASC, 
	  "RUNWAYNR"		ASC, 
	  "FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE INDEX "DB2ADMIN"."I34"
	ON "DB2ADMIN"."PARKINGSLOT_ASSIGNED_TO"
	("PARKINGSLOTID"		ASC, 
	  "APCODE"		ASC, 
	  "FLIGHTNR"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE UNIQUE INDEX "AJAY"."CUST_CID_XMLIDX"
	ON "AJAY"."CUSTOMER"
	("INFO"		ASC) GENERATE KEY USING XMLPATTERN '/customerinfo/@Cid' AS SQL DOUBLE IGNORE INVALID VALUES
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

CREATE UNIQUE INDEX "AJAY"."XACT2"
	ON "AJAY"."ACT"
	("ACTNO"		ASC, 
	  "ACTKWD"		ASC)
	MINPCTUSED 0
	ALLOW REVERSE SCANS
	PAGE SPLIT SYMMETRIC
	COLLECT STATISTICS
	COMPRESS NO;

ALTER TABLE "AJAY"."ACT" ADD CONSTRAINT "PK_ACT" PRIMARY KEY
	("ACTNO");

ALTER TABLE "AJAY"."CATALOG" ADD CONSTRAINT "PK_CATALOG" PRIMARY KEY
	("NAME");

ALTER TABLE "AJAY"."CUSTOMER" ADD CONSTRAINT "PK_CUSTOMER" PRIMARY KEY
	("CID");

ALTER TABLE "AJAY"."DEPARTMENT" ADD CONSTRAINT "PK_DEPARTMENT" PRIMARY KEY
	("DEPTNO");

ALTER TABLE "AJAY"."EMPLOYEE" ADD CONSTRAINT "NUMBER" CHECK (PHONENO >= '0000' AND PHONENO <= '9999');

ALTER TABLE "AJAY"."EMPLOYEE" ADD CONSTRAINT "PK_EMPLOYEE" PRIMARY KEY
	("EMPNO");

ALTER TABLE "AJAY"."EMP_PHOTO" ADD CONSTRAINT "PK_EMP_PHOTO" PRIMARY KEY
	("EMPNO", 
	 "PHOTO_FORMAT");

ALTER TABLE "AJAY"."EMP_RESUME" ADD CONSTRAINT "PK_EMP_RESUME" PRIMARY KEY
	("EMPNO", 
	 "RESUME_FORMAT");

ALTER TABLE "AJAY"."INVENTORY" ADD CONSTRAINT "PK_INVENTORY" PRIMARY KEY
	("PID");

ALTER TABLE "AJAY"."PRODUCT" ADD CONSTRAINT "PK_PRODUCT" PRIMARY KEY
	("PID");

ALTER TABLE "AJAY"."PRODUCTSUPPLIER" ADD CONSTRAINT "PK_PRODUCTSUPPLIER" PRIMARY KEY
	("PID", 
	 "SID");

ALTER TABLE "AJAY"."PROJACT" ADD CONSTRAINT "PK_PROJACT" PRIMARY KEY
	("PROJNO", 
	 "ACTNO", 
	 "ACSTDATE");

ALTER TABLE "AJAY"."PROJECT" ADD CONSTRAINT "PK_PROJECT" PRIMARY KEY
	("PROJNO");

ALTER TABLE "AJAY"."PURCHASEORDER" ADD CONSTRAINT "PK_PURCHASEORDER" PRIMARY KEY
	("POID");

ALTER TABLE "AJAY"."SUPPLIERS" ADD CONSTRAINT "PK_PRODUCTSUPPLIER" PRIMARY KEY
	("SID");

ALTER TABLE "DB2ADMIN"."ABBREVIATION" ADD CONSTRAINT "ABBREVIATION_PK" PRIMARY KEY
	("ABB_TEXT");

ALTER TABLE "DB2ADMIN"."ADDRESS" ADD CONSTRAINT "ADDRESS_PK" PRIMARY KEY
	("ADID");

ALTER TABLE "DB2ADMIN"."AGENT" ADD CONSTRAINT "AGENT_PK" PRIMARY KEY
	("AGENTID");

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_PK" PRIMARY KEY
	("ALID");

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_UK1" UNIQUE
	("ABB_TEXT");

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_UK2" UNIQUE
	("ADID");

ALTER TABLE "DB2ADMIN"."AIRPLANE" ADD CONSTRAINT "AIRPLANE_PK" PRIMARY KEY
	("APID");

ALTER TABLE "DB2ADMIN"."AIRPLANETYPE" ADD CONSTRAINT "AIRPLANETYPE_PK" PRIMARY KEY
	("ATID");

ALTER TABLE "DB2ADMIN"."AIRPORT" ADD CONSTRAINT "AIRPORT_PK" PRIMARY KEY
	("APCODE");

ALTER TABLE "DB2ADMIN"."AREA" ADD CONSTRAINT "AREA_PK" PRIMARY KEY
	("AREAID");

ALTER TABLE "DB2ADMIN"."AREA" ADD CONSTRAINT "AREA_U" UNIQUE
	("AREANUMBER", 
	 "APCODE");

ALTER TABLE "DB2ADMIN"."AREA_RENTED_BY" ADD CONSTRAINT "ARB_PK" PRIMARY KEY
	("AREAID", 
	 "TENANTID", 
	 "RENTSTARTDATE", 
	 "RENTENDDATE");

ALTER TABLE "DB2ADMIN"."AREA_RENTED_BY" ADD CONSTRAINT "CORRECT_DATE" CHECK (RENTSTARTDATE < RENTENDDATE);

ALTER TABLE "DB2ADMIN"."ASSIGNED_TO_CATERING_FACILITY" ADD CONSTRAINT "ASSIGNED_TO_CATERING_FACILITY_PK" PRIMARY KEY
	("KSID", 
	 "CFID", 
	 "STARTTIMESTAMP");

ALTER TABLE "DB2ADMIN"."ATTACHES_WITH" ADD CONSTRAINT "ATTACHES_WITH_PK1" PRIMARY KEY
	("BOARDINGPASSID", 
	 "LUGGAGEID");

ALTER TABLE "DB2ADMIN"."ATTENDENT" ADD CONSTRAINT "ATTENDENT_PK" PRIMARY KEY
	("ATT_ID");

ALTER TABLE "DB2ADMIN"."ATTENDENT" ADD CONSTRAINT "ATTENDENT_UK" UNIQUE
	("CREW_ID");

ALTER TABLE "DB2ADMIN"."BOARDINGPASS" ADD CONSTRAINT "BOARDINGPASS_PK" PRIMARY KEY
	("BOARDINGPASSID");

ALTER TABLE "DB2ADMIN"."CATERING" ADD CONSTRAINT "CATERING_PK1" PRIMARY KEY
	("CATID");

ALTER TABLE "DB2ADMIN"."CATERINGFACILITY" ADD CONSTRAINT "CATERINGFACILITY_PK" PRIMARY KEY
	("CFID");

ALTER TABLE "DB2ADMIN"."CHECKIN" ADD CONSTRAINT "CHECKIN_PK" PRIMARY KEY
	("CHKINCOUNTERNR", 
	 "CHECKINTIME", 
	 "PASSENGERID");

ALTER TABLE "DB2ADMIN"."CHECKINCOUNTER" ADD CONSTRAINT "CHINCNTR_PK" PRIMARY KEY
	("CHKINCOUNTERNR");

ALTER TABLE "DB2ADMIN"."CHECKINPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_PK" PRIMARY KEY
	("CHPID");

ALTER TABLE "DB2ADMIN"."CHECKINPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_U" UNIQUE
	("PSID");

ALTER TABLE "DB2ADMIN"."CMEM_HAS_ADMISSION" ADD CONSTRAINT "CMEM_HAS_ADMISSION_PK" PRIMARY KEY
	("CMID", 
	 "ATID");

ALTER TABLE "DB2ADMIN"."CODE_DEFINITION" ADD CONSTRAINT "CODE_DEFINITION_PK" PRIMARY KEY
	("CODE");

ALTER TABLE "DB2ADMIN"."CONTACTS" ADD CONSTRAINT "CONTACTS_PK" PRIMARY KEY
	("CUSTOMERID", 
	 "AGENTID");

ALTER TABLE "DB2ADMIN"."CREW" ADD CONSTRAINT "CREW_PK" PRIMARY KEY
	("CREW_ID");

ALTER TABLE "DB2ADMIN"."CREW_MEMBER" ADD CONSTRAINT "CREW_MEMBER_PK" PRIMARY KEY
	("CMID");

ALTER TABLE "DB2ADMIN"."CREW_MEMBER" ADD CONSTRAINT "CREW_MEMBER_U" UNIQUE
	("PSID");

ALTER TABLE "DB2ADMIN"."CUSTOMER" ADD CONSTRAINT "CUSTOMER_PK" PRIMARY KEY
	("CUSTOMERID");

ALTER TABLE "DB2ADMIN"."DELAY" ADD CONSTRAINT "DELAY_PK" PRIMARY KEY
	("DID");

ALTER TABLE "DB2ADMIN"."FARE" ADD CONSTRAINT "FARE_PK" PRIMARY KEY
	("TYPE");

ALTER TABLE "DB2ADMIN"."FLIGHT" ADD CONSTRAINT "FLIGHT_PK" PRIMARY KEY
	("FLIGHTID");

ALTER TABLE "DB2ADMIN"."FLIGHTCONTROLLER" ADD CONSTRAINT "FLIGHTCONTROLLER_PK1" PRIMARY KEY
	("FCONTROLLERID");

ALTER TABLE "DB2ADMIN"."FLIGHTSEGMENT" ADD CONSTRAINT "FLIGHTSEGMENT_PK" PRIMARY KEY
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FLIGHT_CONSISTS_OF" ADD CONSTRAINT "FLOWN_BY_AIRPLANE_PK" PRIMARY KEY
	("FLIGHTID", 
	 "FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FLIGHT_ORDERS" ADD CONSTRAINT "FLIGHT_ORDERS_PK" PRIMARY KEY
	("ORDER_NO");

ALTER TABLE "DB2ADMIN"."HISTORY" ADD CONSTRAINT "HISTORY_PK" PRIMARY KEY
	("TENANTID", 
	 "HRENTSTARTDATE");

ALTER TABLE "DB2ADMIN"."INCLUDES" ADD CONSTRAINT "INCLUDES_PK1" PRIMARY KEY
	("CATID", 
	 "SEGMENTTICKETID");

ALTER TABLE "DB2ADMIN"."KITCHEN_STAFF" ADD CONSTRAINT "KITCHEN_STAFF_PK" PRIMARY KEY
	("KSID");

ALTER TABLE "DB2ADMIN"."KITCHEN_STAFF" ADD CONSTRAINT "KITCHEN_STAFF_U" UNIQUE
	("PSID");

ALTER TABLE "DB2ADMIN"."LUGGAGE" ADD CONSTRAINT "LUGGAGE_PK" PRIMARY KEY
	("LUGGAGEID");

ALTER TABLE "DB2ADMIN"."LUGGAGE_TAGGED_BY" ADD CONSTRAINT "LTBY_PK" PRIMARY KEY
	("LUGGAGEID", 
	 "TAGTIMESTAMP");

ALTER TABLE "DB2ADMIN"."MAINTENANCEPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_PK" PRIMARY KEY
	("MPID");

ALTER TABLE "DB2ADMIN"."MAINTENANCEPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_U" UNIQUE
	("PSID");

ALTER TABLE "DB2ADMIN"."M_WORKS_IN" ADD CONSTRAINT "M_WORKS_IN_PK" PRIMARY KEY
	("MPID", 
	 "APCODE", 
	 "STARTTIMESTAMP");

ALTER TABLE "DB2ADMIN"."ORDERED_BY" ADD CONSTRAINT "ORDERED_BY_PK" PRIMARY KEY
	("CATID", 
	 "CUSTOMERID");

ALTER TABLE "DB2ADMIN"."PARKINGSLOT" ADD CONSTRAINT "PARKINGSLOT_PK1" PRIMARY KEY
	("APCODE", 
	 "PARKINGSLOTID");

ALTER TABLE "DB2ADMIN"."PARKINGSLOTLOG" ADD CONSTRAINT "PARKINGSLOTLOG_PK" PRIMARY KEY
	("PARKINGSLOTID", 
	 "PARKINGTIMESTAMP");

ALTER TABLE "DB2ADMIN"."PARKINGSLOT_ASSIGNED_TO" ADD CONSTRAINT "PARKINGSLOT_ASSIGNED_TO_PK" PRIMARY KEY
	("PARKINGSLOTID", 
	 "PS_TIMESTAMP");

ALTER TABLE "DB2ADMIN"."PASSENGER" ADD CONSTRAINT "PASSENGER_PK" PRIMARY KEY
	("PASSENGERID");

ALTER TABLE "DB2ADMIN"."PERSON" ADD CONSTRAINT "PERSON_PK" PRIMARY KEY
	("PID");

ALTER TABLE "DB2ADMIN"."PERSONNEL" ADD CONSTRAINT "PERSONNEL_PK" PRIMARY KEY
	("PSID");

ALTER TABLE "DB2ADMIN"."PERSONNEL" ADD CONSTRAINT "PERSONNEL_U" UNIQUE
	("PID");

ALTER TABLE "DB2ADMIN"."PERSONNEL_ASSIGNED_TO_CHECKIN" ADD CONSTRAINT "PERSONNEL_ASSIGNED_TO_CHECKIN_PK" PRIMARY KEY
	("CHPID", 
	 "CHKINCOUNTERNR", 
	 "STARTTIMESTAMP");

ALTER TABLE "DB2ADMIN"."PILOT" ADD CONSTRAINT "PILOT_PK" PRIMARY KEY
	("PILOT_ID");

ALTER TABLE "DB2ADMIN"."PILOT" ADD CONSTRAINT "PILOT_UK" UNIQUE
	("CREW_ID");

ALTER TABLE "DB2ADMIN"."PROVIDE" ADD CONSTRAINT "PROVIDE_PK1" PRIMARY KEY
	("CFID", 
	 "CATID");

ALTER TABLE "DB2ADMIN"."ROUTE" ADD CONSTRAINT "ROUTE_PK" PRIMARY KEY
	("ROUTEID");

ALTER TABLE "DB2ADMIN"."RUNWAY" ADD CONSTRAINT "RUNWAY_PK1" PRIMARY KEY
	("APCODE", 
	 "RUNWAYNR");

ALTER TABLE "DB2ADMIN"."RUNWAYLOG" ADD CONSTRAINT "RUNWAYLOG_PK" PRIMARY KEY
	("RUNWAYNR", 
	 "RUNWAYTIMESTAMP");

ALTER TABLE "DB2ADMIN"."RUNWAY_USED_BY" ADD CONSTRAINT "RUNWAY_USED_BY_PK" PRIMARY KEY
	("RUNWAYNR", 
	 "RW_TIMESTAMP");

ALTER TABLE "DB2ADMIN"."SCHEDULEDMAINTENANCE" ADD CONSTRAINT "SCHEDULEDMAINTENANCE_PK" PRIMARY KEY
	("SMID");

ALTER TABLE "DB2ADMIN"."SEATS" ADD CONSTRAINT "SEATS_PK" PRIMARY KEY
	("ATID", 
	 "SNUMBER");

ALTER TABLE "DB2ADMIN"."SEGMENTTICKET" ADD CONSTRAINT "SEGMENTTICKET_PK" PRIMARY KEY
	("SEGMENTTICKETID");

ALTER TABLE "DB2ADMIN"."TECHNICAL_NOTE" ADD CONSTRAINT "TECHNICAL_NOTE_PK" PRIMARY KEY
	("TNID");

ALTER TABLE "DB2ADMIN"."TENANT" ADD CONSTRAINT "TENANT_PK" PRIMARY KEY
	("TENANTID");

ALTER TABLE "DB2ADMIN"."TICKET" ADD CONSTRAINT "TICKET_PK" PRIMARY KEY
	("TICKETID");

ALTER TABLE "DB2ADMIN"."TICKET_CONSISTS_SEGMENT" ADD CONSTRAINT "TICKET_CONSISTS_SEGMENT_PK" PRIMARY KEY
	("TICKETID", 
	 "SEGMENTTICKETID");

ALTER TABLE "DB2ADMIN"."TRANSACTIONS" ADD CONSTRAINT "TRANSACTIONS_PK" PRIMARY KEY
	("AGENTID");

ALTER TABLE "SYSTOOLS"."HMON_ATM_INFO" ADD CONSTRAINT "ATM_UNIQ" UNIQUE
	("SCHEMA", 
	 "NAME");

ALTER TABLE "SYSTOOLS"."HMON_COLLECTION" ADD CONSTRAINT "HI_OBJ_UNIQ" UNIQUE
	("HI_ID", 
	 "OBJ_NAME1", 
	 "OBJ_NAME2", 
	 "OBJ_NAME3");

ALTER TABLE "SYSTOOLS"."POLICY" ADD CONSTRAINT "POLICY_UNQ" UNIQUE
	("MED", 
	 "DECISION", 
	 "NAME");

ALTER TABLE "AJAY"."ACT" ADD CONSTRAINT "RPAA" FOREIGN KEY
	("ACTNO")
	REFERENCES "AJAY"."ACT"
	("ACTNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."DEPARTMENT" ADD CONSTRAINT "RDE" FOREIGN KEY
	("MGRNO")
	REFERENCES "AJAY"."EMPLOYEE"
	("EMPNO")
	ON DELETE SET NULL;

ALTER TABLE "AJAY"."DEPARTMENT" ADD CONSTRAINT "ROD" FOREIGN KEY
	("ADMRDEPT")
	REFERENCES "AJAY"."DEPARTMENT"
	("DEPTNO")
	ON DELETE CASCADE;

ALTER TABLE "AJAY"."EMPLOYEE" ADD CONSTRAINT "RED" FOREIGN KEY
	("WORKDEPT")
	REFERENCES "AJAY"."DEPARTMENT"
	("DEPTNO")
	ON DELETE SET NULL;

ALTER TABLE "AJAY"."EMPPROJACT" ADD CONSTRAINT "REPAPA" FOREIGN KEY
	("PROJNO", 
	 "ACTNO", 
	 "EMSTDATE")
	REFERENCES "AJAY"."PROJACT"
	("PROJNO", 
	 "ACTNO", 
	 "ACSTDATE")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."EMP_PHOTO" ADD CONSTRAINT "FK_EMP_PHOTO" FOREIGN KEY
	("EMPNO")
	REFERENCES "AJAY"."EMPLOYEE"
	("EMPNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."EMP_RESUME" ADD CONSTRAINT "FK_EMP_RESUME" FOREIGN KEY
	("EMPNO")
	REFERENCES "AJAY"."EMPLOYEE"
	("EMPNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."PROJACT" ADD CONSTRAINT "RPAP" FOREIGN KEY
	("PROJNO")
	REFERENCES "AJAY"."PROJECT"
	("PROJNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."PROJECT" ADD CONSTRAINT "FK_PROJECT_1" FOREIGN KEY
	("DEPTNO")
	REFERENCES "AJAY"."DEPARTMENT"
	("DEPTNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."PROJECT" ADD CONSTRAINT "FK_PROJECT_2" FOREIGN KEY
	("RESPEMP")
	REFERENCES "AJAY"."EMPLOYEE"
	("EMPNO")
	ON DELETE RESTRICT;

ALTER TABLE "AJAY"."PROJECT" ADD CONSTRAINT "RPP" FOREIGN KEY
	("MAJPROJ")
	REFERENCES "AJAY"."PROJECT"
	("PROJNO")
	ON DELETE CASCADE;

ALTER TABLE "AJAY"."PURCHASEORDER" ADD CONSTRAINT "FK_PO_CUST" FOREIGN KEY
	("CUSTID")
	REFERENCES "AJAY"."CUSTOMER"
	("CID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_FK1" FOREIGN KEY
	("ABB_TEXT")
	REFERENCES "DB2ADMIN"."ABBREVIATION"
	("ABB_TEXT");

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_FK2" FOREIGN KEY
	("ADID")
	REFERENCES "DB2ADMIN"."ADDRESS"
	("ADID");

ALTER TABLE "DB2ADMIN"."AIRLINE" ADD CONSTRAINT "AIRLINE_FK3" FOREIGN KEY
	("CFID")
	REFERENCES "DB2ADMIN"."CATERINGFACILITY"
	("CFID");

ALTER TABLE "DB2ADMIN"."AIRPLANE" ADD CONSTRAINT "AIRPLANE_FK1" FOREIGN KEY
	("ATID")
	REFERENCES "DB2ADMIN"."AIRPLANETYPE"
	("ATID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."AIRPLANE" ADD CONSTRAINT "AIRPLANE_FK2" FOREIGN KEY
	("ALID")
	REFERENCES "DB2ADMIN"."AIRLINE"
	("ALID");

ALTER TABLE "DB2ADMIN"."AREA" ADD CONSTRAINT "AREA_FK" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."AREA_RENTED_BY" ADD CONSTRAINT "ARB_FK1" FOREIGN KEY
	("AREAID")
	REFERENCES "DB2ADMIN"."AREA"
	("AREAID");

ALTER TABLE "DB2ADMIN"."AREA_RENTED_BY" ADD CONSTRAINT "ARB_FK2" FOREIGN KEY
	("TENANTID")
	REFERENCES "DB2ADMIN"."TENANT"
	("TENANTID");

ALTER TABLE "DB2ADMIN"."ASSIGNED_TO_CATERING_FACILITY" ADD CONSTRAINT "ASSIGNED_TO_CATERING_FACILITY_FK1" FOREIGN KEY
	("KSID")
	REFERENCES "DB2ADMIN"."KITCHEN_STAFF"
	("KSID");

ALTER TABLE "DB2ADMIN"."ASSIGNED_TO_CATERING_FACILITY" ADD CONSTRAINT "ASSIGNED_TO_CATERING_FACILITY_FK2" FOREIGN KEY
	("CFID")
	REFERENCES "DB2ADMIN"."CATERINGFACILITY"
	("CFID");

ALTER TABLE "DB2ADMIN"."ATTACHES_WITH" ADD CONSTRAINT "ATTACHES_WITH_FK1" FOREIGN KEY
	("BOARDINGPASSID")
	REFERENCES "DB2ADMIN"."BOARDINGPASS"
	("BOARDINGPASSID");

ALTER TABLE "DB2ADMIN"."ATTACHES_WITH" ADD CONSTRAINT "ATTACHES_WITH_FK2" FOREIGN KEY
	("LUGGAGEID")
	REFERENCES "DB2ADMIN"."LUGGAGE"
	("LUGGAGEID");

ALTER TABLE "DB2ADMIN"."ATTENDENT" ADD CONSTRAINT "ATTENDENT_FK1" FOREIGN KEY
	("CREW_ID")
	REFERENCES "DB2ADMIN"."CREW"
	("CREW_ID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."ATTENDENT" ADD CONSTRAINT "ATTENDENT_FK2" FOREIGN KEY
	("CMID")
	REFERENCES "DB2ADMIN"."CREW_MEMBER"
	("CMID");

ALTER TABLE "DB2ADMIN"."BOARDINGPASS" ADD CONSTRAINT "BOARDINGPASS_FK1" FOREIGN KEY
	("PASSENGERID")
	REFERENCES "DB2ADMIN"."PASSENGER"
	("PASSENGERID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."CATERINGFACILITY" ADD CONSTRAINT "CATERINGFACILITY_FK1" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE");

ALTER TABLE "DB2ADMIN"."CHECKIN" ADD CONSTRAINT "CHECKIN_FK1" FOREIGN KEY
	("CHKINCOUNTERNR")
	REFERENCES "DB2ADMIN"."CHECKINCOUNTER"
	("CHKINCOUNTERNR");

ALTER TABLE "DB2ADMIN"."CHECKIN" ADD CONSTRAINT "CHECKIN_FK2" FOREIGN KEY
	("PASSENGERID")
	REFERENCES "DB2ADMIN"."PASSENGER"
	("PASSENGERID");

ALTER TABLE "DB2ADMIN"."CHECKINCOUNTER" ADD CONSTRAINT "CHINCNTR_FK" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."CHECKINPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_FK" FOREIGN KEY
	("PSID")
	REFERENCES "DB2ADMIN"."PERSONNEL"
	("PSID");

ALTER TABLE "DB2ADMIN"."CMEM_HAS_ADMISSION" ADD CONSTRAINT "CMEM_HAS_ADMISSION_FK1" FOREIGN KEY
	("CMID")
	REFERENCES "DB2ADMIN"."CREW_MEMBER"
	("CMID");

ALTER TABLE "DB2ADMIN"."CMEM_HAS_ADMISSION" ADD CONSTRAINT "CMEM_HAS_ADMISSION_FK2" FOREIGN KEY
	("ATID")
	REFERENCES "DB2ADMIN"."AIRPLANETYPE"
	("ATID");

ALTER TABLE "DB2ADMIN"."CONTACTS" ADD CONSTRAINT "CONTACTS_FK1" FOREIGN KEY
	("AGENTID")
	REFERENCES "DB2ADMIN"."AGENT"
	("AGENTID");

ALTER TABLE "DB2ADMIN"."CONTACTS" ADD CONSTRAINT "CONTACTS_FK2" FOREIGN KEY
	("CUSTOMERID")
	REFERENCES "DB2ADMIN"."CUSTOMER"
	("CUSTOMERID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."CREW_MEMBER" ADD CONSTRAINT "CREW_MEMBER_FK1" FOREIGN KEY
	("PSID")
	REFERENCES "DB2ADMIN"."PERSONNEL"
	("PSID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."DELAY" ADD CONSTRAINT "DELAY_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FARE" ADD CONSTRAINT "FARE_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FLIGHTSEGMENT" ADD CONSTRAINT "FLIGHTSEGMENT_FK1" FOREIGN KEY
	("ROUTEID")
	REFERENCES "DB2ADMIN"."ROUTE"
	("ROUTEID");

ALTER TABLE "DB2ADMIN"."FLIGHTSEGMENT" ADD CONSTRAINT "FLIGHTSEGMENT_FK2" FOREIGN KEY
	("CREW_ID")
	REFERENCES "DB2ADMIN"."CREW"
	("CREW_ID");

ALTER TABLE "DB2ADMIN"."FLIGHTSEGMENT" ADD CONSTRAINT "FLIGHTSEGMENT_FK3" FOREIGN KEY
	("APID")
	REFERENCES "DB2ADMIN"."AIRPLANE"
	("APID");

ALTER TABLE "DB2ADMIN"."FLIGHT_CONSISTS_OF" ADD CONSTRAINT "FLOWN_BY_AIRPLANE_FK1" FOREIGN KEY
	("FLIGHTID")
	REFERENCES "DB2ADMIN"."FLIGHT"
	("FLIGHTID");

ALTER TABLE "DB2ADMIN"."FLIGHT_CONSISTS_OF" ADD CONSTRAINT "FLOWN_BY_AIRPLANE_FK2" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FLIGHT_ORDERS" ADD CONSTRAINT "FLIGHT_ORDERS_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."FLIGHT_ORDERS" ADD CONSTRAINT "FLIGHT_ORDERS_FK2" FOREIGN KEY
	("CATID")
	REFERENCES "DB2ADMIN"."CATERING"
	("CATID");

ALTER TABLE "DB2ADMIN"."HISTORY" ADD CONSTRAINT "HISTORY_FK1" FOREIGN KEY
	("TENANTID")
	REFERENCES "DB2ADMIN"."TENANT"
	("TENANTID");

ALTER TABLE "DB2ADMIN"."INCLUDES" ADD CONSTRAINT "INCLUDES_FK1" FOREIGN KEY
	("CATID")
	REFERENCES "DB2ADMIN"."CATERING"
	("CATID");

ALTER TABLE "DB2ADMIN"."INCLUDES" ADD CONSTRAINT "INCLUDES_FK2" FOREIGN KEY
	("SEGMENTTICKETID")
	REFERENCES "DB2ADMIN"."SEGMENTTICKET"
	("SEGMENTTICKETID");

ALTER TABLE "DB2ADMIN"."KITCHEN_STAFF" ADD CONSTRAINT "KITCHEN_STAFF_FK" FOREIGN KEY
	("PSID")
	REFERENCES "DB2ADMIN"."PERSONNEL"
	("PSID");

ALTER TABLE "DB2ADMIN"."LUGGAGE_TAGGED_BY" ADD CONSTRAINT "LTBY_FK1" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."LUGGAGE_TAGGED_BY" ADD CONSTRAINT "LTBY_FK2" FOREIGN KEY
	("LUGGAGEID")
	REFERENCES "DB2ADMIN"."LUGGAGE"
	("LUGGAGEID");

ALTER TABLE "DB2ADMIN"."LUGGAGE_TAGGED_BY" ADD CONSTRAINT "LTBY_FK3" FOREIGN KEY
	("CHKINCOUNTERNR")
	REFERENCES "DB2ADMIN"."CHECKINCOUNTER"
	("CHKINCOUNTERNR");

ALTER TABLE "DB2ADMIN"."MAINTENANCEPERSONNEL" ADD CONSTRAINT "MAINTENANCEPERSONNEL_FK" FOREIGN KEY
	("PSID")
	REFERENCES "DB2ADMIN"."PERSONNEL"
	("PSID");

ALTER TABLE "DB2ADMIN"."M_WORKS_IN" ADD CONSTRAINT "M_WORKS_IN_FK1" FOREIGN KEY
	("MPID")
	REFERENCES "DB2ADMIN"."MAINTENANCEPERSONNEL"
	("MPID");

ALTER TABLE "DB2ADMIN"."M_WORKS_IN" ADD CONSTRAINT "M_WORKS_IN_FK2" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE");

ALTER TABLE "DB2ADMIN"."ORDERED_BY" ADD CONSTRAINT "ORDERED_BY_FK1" FOREIGN KEY
	("CATID")
	REFERENCES "DB2ADMIN"."TICKET"
	("TICKETID");

ALTER TABLE "DB2ADMIN"."ORDERED_BY" ADD CONSTRAINT "ORDERED_BY_FK2" FOREIGN KEY
	("CUSTOMERID")
	REFERENCES "DB2ADMIN"."CUSTOMER"
	("CUSTOMERID");

ALTER TABLE "DB2ADMIN"."PARKINGSLOT" ADD CONSTRAINT "PARKINGSLOT_FK" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."PARKINGSLOTLOG" ADD CONSTRAINT "PARKINGSLOTLOG_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."PARKINGSLOT_ASSIGNED_TO" ADD CONSTRAINT "PARKINGSLOT_ASSIGNED_TO_FK1" FOREIGN KEY
	("APCODE", 
	 "PARKINGSLOTID")
	REFERENCES "DB2ADMIN"."PARKINGSLOT"
	("APCODE", 
	 "PARKINGSLOTID");

ALTER TABLE "DB2ADMIN"."PARKINGSLOT_ASSIGNED_TO" ADD CONSTRAINT "PARKINGSLOT_ASSIGNED_TO_FK2" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."PASSENGER" ADD CONSTRAINT "PASSENGER_FK" FOREIGN KEY
	("PASSENGERID")
	REFERENCES "DB2ADMIN"."CUSTOMER"
	("CUSTOMERID");

ALTER TABLE "DB2ADMIN"."PERSONNEL" ADD CONSTRAINT "PERSONNEL_FK1" FOREIGN KEY
	("PID")
	REFERENCES "DB2ADMIN"."PERSON"
	("PID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."PERSONNEL_ASSIGNED_TO_CHECKIN" ADD CONSTRAINT "PERSONNEL_ASSIGNED_TO_CHECKIN_FK1" FOREIGN KEY
	("CHPID")
	REFERENCES "DB2ADMIN"."CHECKINPERSONNEL"
	("CHPID");

ALTER TABLE "DB2ADMIN"."PERSONNEL_ASSIGNED_TO_CHECKIN" ADD CONSTRAINT "PERSONNEL_ASSIGNED_TO_CHECKIN_FK2" FOREIGN KEY
	("CHKINCOUNTERNR")
	REFERENCES "DB2ADMIN"."CHECKINCOUNTER"
	("CHKINCOUNTERNR");

ALTER TABLE "DB2ADMIN"."PILOT" ADD CONSTRAINT "PILOT_FK1" FOREIGN KEY
	("CREW_ID")
	REFERENCES "DB2ADMIN"."CREW"
	("CREW_ID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."PILOT" ADD CONSTRAINT "PILOT_FK2" FOREIGN KEY
	("CMID")
	REFERENCES "DB2ADMIN"."CREW_MEMBER"
	("CMID");

ALTER TABLE "DB2ADMIN"."PROVIDE" ADD CONSTRAINT "PROVIDE_FK1" FOREIGN KEY
	("CFID")
	REFERENCES "DB2ADMIN"."CATERINGFACILITY"
	("CFID");

ALTER TABLE "DB2ADMIN"."PROVIDE" ADD CONSTRAINT "PROVIDE_FK2" FOREIGN KEY
	("CATID")
	REFERENCES "DB2ADMIN"."CATERING"
	("CATID");

ALTER TABLE "DB2ADMIN"."ROUTE" ADD CONSTRAINT "ROUTE_FK1" FOREIGN KEY
	("APCODE_SRC")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."ROUTE" ADD CONSTRAINT "ROUTE_FK2" FOREIGN KEY
	("APCODE_DST")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."RUNWAY" ADD CONSTRAINT "RUNWAY_FK1" FOREIGN KEY
	("FCONTROLLERID")
	REFERENCES "DB2ADMIN"."FLIGHTCONTROLLER"
	("FCONTROLLERID");

ALTER TABLE "DB2ADMIN"."RUNWAY" ADD CONSTRAINT "RUNWAY_FK2" FOREIGN KEY
	("APCODE")
	REFERENCES "DB2ADMIN"."AIRPORT"
	("APCODE")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."RUNWAYLOG" ADD CONSTRAINT "RUNWAYLOG_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."RUNWAY_USED_BY" ADD CONSTRAINT "RUNWAY_USED_BY_FK1" FOREIGN KEY
	("APCODE", 
	 "RUNWAYNR")
	REFERENCES "DB2ADMIN"."RUNWAY"
	("APCODE", 
	 "RUNWAYNR");

ALTER TABLE "DB2ADMIN"."RUNWAY_USED_BY" ADD CONSTRAINT "RUNWAY_USED_BY_FK2" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."SCHEDULEDMAINTENANCE" ADD CONSTRAINT "SCHEDULEDMAINTENANCE_FK" FOREIGN KEY
	("APID")
	REFERENCES "DB2ADMIN"."AIRPLANE"
	("APID");

ALTER TABLE "DB2ADMIN"."SEATS" ADD CONSTRAINT "SEATS_FK1" FOREIGN KEY
	("ATID")
	REFERENCES "DB2ADMIN"."AIRPLANETYPE"
	("ATID")
	ON DELETE CASCADE;

ALTER TABLE "DB2ADMIN"."SEGMENTTICKET" ADD CONSTRAINT "SEGMENTTICKET_FK1" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."TECHNICAL_NOTE" ADD CONSTRAINT "TECHNICAL_NOTE_FK1" FOREIGN KEY
	("MPID")
	REFERENCES "DB2ADMIN"."MAINTENANCEPERSONNEL"
	("MPID");

ALTER TABLE "DB2ADMIN"."TECHNICAL_NOTE" ADD CONSTRAINT "TECHNICAL_NOTE_FK2" FOREIGN KEY
	("CODE")
	REFERENCES "DB2ADMIN"."CODE_DEFINITION"
	("CODE");

ALTER TABLE "DB2ADMIN"."TECHNICAL_NOTE" ADD CONSTRAINT "TECHNICAL_NOTE_FK3" FOREIGN KEY
	("FLIGHTNR")
	REFERENCES "DB2ADMIN"."FLIGHTSEGMENT"
	("FLIGHTNR");

ALTER TABLE "DB2ADMIN"."TICKET" ADD CONSTRAINT "TICKET_FK1" FOREIGN KEY
	("CUSTOMERID")
	REFERENCES "DB2ADMIN"."CUSTOMER"
	("CUSTOMERID");

ALTER TABLE "DB2ADMIN"."TICKET" ADD CONSTRAINT "TICKET_FK2" FOREIGN KEY
	("FLIGHTID")
	REFERENCES "DB2ADMIN"."FLIGHT"
	("FLIGHTID");

ALTER TABLE "DB2ADMIN"."TICKET_CONSISTS_SEGMENT" ADD CONSTRAINT "TICKET_CONSISTS_SEGMENT_FK1" FOREIGN KEY
	("TICKETID")
	REFERENCES "DB2ADMIN"."TICKET"
	("TICKETID");

ALTER TABLE "DB2ADMIN"."TICKET_CONSISTS_SEGMENT" ADD CONSTRAINT "TICKET_CONSISTS_SEGMENT_FK2" FOREIGN KEY
	("SEGMENTTICKETID")
	REFERENCES "DB2ADMIN"."SEGMENTTICKET"
	("SEGMENTTICKETID");

ALTER TABLE "DB2ADMIN"."TRANSACTIONS" ADD CONSTRAINT "TRANSACTIONS_AGENT_FK1" FOREIGN KEY
	("AGENTID")
	REFERENCES "DB2ADMIN"."AGENT"
	("AGENTID");

ALTER TABLE "DB2ADMIN"."TRANSACTIONS" ADD CONSTRAINT "TRANSACTIONS_AGENT_FK2" FOREIGN KEY
	("FLIGHTID")
	REFERENCES "DB2ADMIN"."FLIGHT"
	("FLIGHTID");

CREATE TABLE "AJAY"."ADEFUSR" (WORKDEPT, NO_OF_EMPLOYEES )
AS (SELECT workdept, count(*) AS no_of_employees FROM employee GROUP BY workdept)
DATA INITIALLY DEFERRED REFRESH IMMEDIATE ENABLE QUERY OPTIMIZATION
MAINTAINED BY SYSTEM
	COMPRESS NO;

CREATE ALIAS "AJAY"."DEPT" FOR "AJAY"."DEPARTMENT";

CREATE ALIAS "AJAY"."EMP" FOR "AJAY"."EMPLOYEE";

CREATE ALIAS "AJAY"."EMPACT" FOR "AJAY"."EMPPROJACT";

CREATE ALIAS "AJAY"."EMP_ACT" FOR "AJAY"."EMPPROJACT";

CREATE ALIAS "AJAY"."PROJ" FOR "AJAY"."PROJECT";

CREATE VIEW "AJAY"."VACT" ("ACTNO", "ACTKWD", "ACTDESC") AS
SELECT ALL ACTNO ,   ACTKWD ,   ACTDESC FROM ACT;

CREATE VIEW "AJAY"."VDEPMG1" ("DEPTNO", "DEPTNAME", "MGRNO", "FIRSTNME", "MIDINIT", "LASTNAME", "ADMRDEPT") AS
SELECT ALL DEPTNO, DEPTNAME, EMPNO, FIRSTNME, MIDINIT,   LASTNAME, ADMRDEPT FROM DEPT LEFT OUTER  JOIN EMP ON MGRNO = EMPNO;

CREATE VIEW "AJAY"."VASTRDE1" ("DEPT1NO", "DEPT1NAM", "EMP1NO", "EMP1FN", "EMP1MI", "EMP1LN", "TYPE2", "DEPT2NO", "DEPT2NAM", "EMP2NO", "EMP2FN", "EMP2MI", "EMP2LN") AS
SELECT ALL   D1.DEPTNO,D1.DEPTNAME,D1.MGRNO,D1.FIRSTNME,D1.MIDINIT,   D1.LASTNAME, '1',   D2.DEPTNO,D2.DEPTNAME,D2.MGRNO,D2.FIRSTNME,D2.MIDINIT,   D2.LASTNAME FROM VDEPMG1 D1, VDEPMG1 D2 WHERE D1.DEPTNO = D2.ADMRDEPT;

CREATE VIEW "AJAY"."VASTRDE2" ("DEPT1NO", "DEPT1NAM", "EMP1NO", "EMP1FN", "EMP1MI", "EMP1LN", "TYPE2", "DEPT2NO", "DEPT2NAM", "EMP2NO", "EMP2FN", "EMP2MI", "EMP2LN") AS
SELECT ALL   D1.DEPTNO,D1.DEPTNAME,D1.MGRNO,D1.FIRSTNME,D1.MIDINIT,   D1.LASTNAME,'2',   D1.DEPTNO,D1.DEPTNAME,E2.EMPNO,E2.FIRSTNME,E2.MIDINIT,   E2.LASTNAME FROM VDEPMG1 D1, EMP E2 WHERE D1.DEPTNO = E2.WORKDEPT;

CREATE VIEW "AJAY"."VDEPT" ("DEPTNO", "DEPTNAME", "MGRNO", "ADMRDEPT") AS
SELECT ALL DEPTNO,   DEPTNAME,   MGRNO,   ADMRDEPT   FROM DEPT;

CREATE VIEW "AJAY"."VEMP" ("EMPNO", "FIRSTNME", "MIDINIT", "LASTNAME", "WORKDEPT") AS
SELECT ALL EMPNO ,   FIRSTNME,   MIDINIT ,   LASTNAME,   WORKDEPT   FROM EMP;

CREATE VIEW "AJAY"."VEMPDPT1" ("DEPTNO", "DEPTNAME", "EMPNO", "FRSTINIT", "MIDINIT", "LASTNAME", "WORKDEPT") AS
SELECT ALL DEPTNO, DEPTNAME, EMPNO, SUBSTR(FIRSTNME, 1, 1), MIDINIT,   LASTNAME, WORKDEPT FROM DEPT  RIGHT OUTER JOIN EMP ON WORKDEPT = DEPTNO;

CREATE VIEW "AJAY"."VEMPLP" ("EMPLOYEENUMBER", "PHONENUMBER") AS
SELECT ALL EMPNO ,   PHONENO FROM EMP;

CREATE VIEW "AJAY"."VEMPPROJACT" ("EMPNO", "PROJNO", "ACTNO", "EMPTIME", "EMSTDATE", "EMENDATE") AS
SELECT ALL EMPNO, PROJNO, ACTNO, EMPTIME, EMSTDATE, EMENDATE FROM EMPPROJACT;

CREATE VIEW "AJAY"."VPROJRE1" ("PROJNO", "PROJNAME", "PROJDEP", "RESPEMP", "FIRSTNME", "MIDINIT", "LASTNAME", "MAJPROJ") AS
SELECT ALL   PROJNO,PROJNAME,DEPTNO,EMPNO,FIRSTNME,MIDINIT,   LASTNAME,MAJPROJ FROM PROJ, EMP WHERE RESPEMP = EMPNO;

CREATE VIEW "AJAY"."VFORPLA" ("PROJNO", "PROJNAME", "RESPEMP", "PROJDEP", "FRSTINIT", "MIDINIT", "LASTNAME") AS
SELECT ALL F1.PROJNO,PROJNAME,RESPEMP,PROJDEP, SUBSTR(FIRSTNME, 1, 1),   MIDINIT, LASTNAME FROM VPROJRE1 F1 LEFT OUTER JOIN EMPPROJACT F2 ON F1.PROJNO = F2.PROJNO;

CREATE VIEW "AJAY"."VHDEPT" ("DEPTNO", "DEPTNAME", "MGRNO", "ADMRDEPT", "LOCATION") AS
SELECT ALL DEPTNO ,   DEPTNAME,   MGRNO ,   ADMRDEPT,   LOCATION   FROM DEPT;

CREATE VIEW "AJAY"."VPHONE" ("LASTNAME", "FIRSTNAME", "MIDDLEINITIAL", "PHONENUMBER", "EMPLOYEENUMBER", "DEPTNUMBER", "DEPTNAME") AS
SELECT ALL LASTNAME,   FIRSTNME,   MIDINIT ,   VALUE(PHONENO,' '),   EMPNO,   DEPTNO,   DEPTNAME FROM EMP, DEPT WHERE WORKDEPT = DEPTNO;

CREATE VIEW "AJAY"."VPROJ" ("PROJNO", "PROJNAME", "DEPTNO", "RESPEMP", "PRSTAFF", "PRSTDATE", "PRENDATE", "MAJPROJ") AS
SELECT ALL PROJNO, PROJNAME, DEPTNO, RESPEMP, PRSTAFF, PRSTDATE, PRENDATE, MAJPROJ FROM PROJ;

CREATE VIEW "AJAY"."VPROJACT" ("PROJNO", "ACTNO", "ACSTAFF", "ACSTDATE", "ACENDATE") AS
SELECT ALL PROJNO,ACTNO, ACSTAFF, ACSTDATE, ACENDATE FROM PROJACT;

CREATE VIEW "AJAY"."VPSTRDE1" ("PROJ1NO", "PROJ1NAME", "RESP1NO", "RESP1FN", "RESP1MI", "RESP1LN", "PROJ2NO", "PROJ2NAME", "RESP2NO", "RESP2FN", "RESP2MI", "RESP2LN") AS
SELECT ALL   P1.PROJNO,P1.PROJNAME,P1.RESPEMP,P1.FIRSTNME,P1.MIDINIT,   P1.LASTNAME,   P2.PROJNO,P2.PROJNAME,P2.RESPEMP,P2.FIRSTNME,P2.MIDINIT,   P2.LASTNAME FROM VPROJRE1 P1,   VPROJRE1 P2 WHERE P1.PROJNO = P2.MAJPROJ;

CREATE VIEW "AJAY"."VPSTRDE2" ("PROJ1NO", "PROJ1NAME", "RESP1NO", "RESP1FN", "RESP1MI", "RESP1LN", "PROJ2NO", "PROJ2NAME", "RESP2NO", "RESP2FN", "RESP2MI", "RESP2LN") AS
SELECT ALL   P1.PROJNO,P1.PROJNAME,P1.RESPEMP,P1.FIRSTNME,P1.MIDINIT,   P1.LASTNAME,   P1.PROJNO,P1.PROJNAME,P1.RESPEMP,P1.FIRSTNME,P1.MIDINIT,   P1.LASTNAME FROM VPROJRE1 P1 WHERE NOT EXISTS (SELECT * FROM VPROJRE1 P2 WHERE P1.PROJNO = P2.MAJPROJ);

CREATE VIEW "AJAY"."VSTAFAC1" ("PROJNO", "ACTNO", "ACTDESC", "EMPNO", "FIRSTNME", "MIDINIT", "LASTNAME", "EMPTIME", "STDATE", "ENDATE", "TYPE") AS
SELECT ALL PA.PROJNO, PA.ACTNO, AC.ACTDESC,' ', ' ', ' ', ' ',   PA.ACSTAFF, PA.ACSTDATE,   PA.ACENDATE,'1' FROM PROJACT PA, ACT AC  WHERE PA.ACTNO = AC.ACTNO;

CREATE VIEW "AJAY"."VSTAFAC2" ("PROJNO", "ACTNO", "ACTDESC", "EMPNO", "FIRSTNME", "MIDINIT", "LASTNAME", "EMPTIME", "STDATE", "ENDATE", "TYPE") AS
SELECT ALL EP.PROJNO, EP.ACTNO, AC.ACTDESC, EP.EMPNO,EM.FIRSTNME, EM.MIDINIT, EM.LASTNAME, EP.EMPTIME, EP.EMSTDATE,   EP.EMENDATE,'2' FROM EMPPROJACT EP, ACT AC, EMP EM WHERE EP.ACTNO = AC.ACTNO AND EP.EMPNO = EM.EMPNO;

CREATE VIEW "SYSCAT"."ATTRIBUTES" ("TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "ATTR_NAME", "ATTR_TYPESCHEMA", "ATTR_TYPEMODULENAME", "ATTR_TYPENAME", "TARGET_TYPESCHEMA", "TARGET_TYPEMODULENAME", "TARGET_TYPENAME", "SOURCE_TYPESCHEMA", "SOURCE_TYPEMODULENAME", "SOURCE_TYPENAME", "ORDINAL", "LENGTH", "SCALE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "LOGGED", "COMPACT", "DL_FEATURES", "JAVA_FIELDNAME") AS
select 
a.typeschema, m.modulename, a.typename, a.attr_name, a.attr_typeschema, 
ma.modulename, a.attr_typename, a.target_typeschema, mt.modulename, 
a.target_typename, a.source_typeschema, ms.modulename, a.source_typename, 
a.ordinal, a.length, a.scale, a.codepage, 
case when a.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when a.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(a.collationid)) end, 
a.logged, a.compact, 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.ATTRIBUTES.DL_FEATURES'), 
cast ('          ' as char(10))), 
a.java_fieldname 
from sysibm.sysattributes as a 
inner join sysibm.sysdatatypes as d on d.metatype <> 'F' and 
a.typename = d.name and a.typeschema = d.schema and 
(a.typemoduleid = d.typemoduleid or 
a.typemoduleid is null and d.typemoduleid is null) 
left outer join sysibm.syscollations as c on a.collationid = c.collationid 
left outer join sysibm.sysmodules m  on a.typemoduleid=m.moduleid 
left outer join sysibm.sysmodules ma on a.attr_typemoduleid=ma.moduleid 
left outer join sysibm.sysmodules mt on a.target_typemoduleid=mt.moduleid 
left outer join sysibm.sysmodules ms on a.source_typemoduleid=ms.moduleid;

CREATE VIEW "SYSCAT"."AUDITPOLICIES" ("AUDITPOLICYNAME", "AUDITPOLICYID", "CREATE_TIME", "ALTER_TIME", "AUDITSTATUS", "CONTEXTSTATUS", "VALIDATESTATUS", "CHECKINGSTATUS", "SECMAINTSTATUS", "OBJMAINTSTATUS", "SYSADMINSTATUS", "EXECUTESTATUS", "EXECUTEWITHDATA", "ERRORTYPE", "REMARKS") AS
select 
a.auditpolicyname, a.auditpolicyid, a.create_time, 
a.alter_time, a.auditstatus, a.contextstatus, a.validatestatus, 
a.checkingstatus, a.secmaintstatus, a.objmaintstatus, 
a.sysadminstatus, a.executestatus, a.executewithdata, 
a.errortype, b.remarks 
from sysibm.sysauditpolicies as a left outer join sysibm.syscomments as b 
on a.auditpolicyid = b.objectid and b.objecttype='j';

CREATE VIEW "SYSCAT"."AUDITUSE" ("AUDITPOLICYNAME", "AUDITPOLICYID", "OBJECTTYPE", "SUBOBJECTTYPE", "OBJECTSCHEMA", "OBJECTNAME") AS
select 
a.auditpolicyname, a.auditpolicyid, cast('x' as char(1)), 
cast(' ' as char(1)), cast (null as char(1)), b.contextname 
from sysibm.sysauditpolicies a, sysibm.syscontexts b 
where b.auditpolicyid is not null 
and a.auditpolicyid = b.auditpolicyid 
union all 
select a.auditpolicyname, a.auditpolicyid, c.objecttype, 
c.subobjecttype, cast (null as char(1)), c.objectname 
from sysibm.sysauditpolicies a, sysibm.sysaudituse c 
where a.auditpolicyid = c.auditpolicyid 
union all 
select a.auditpolicyname, a.auditpolicyid, 
cast('i' as char(1)), cast('R' as char(1)), cast (null as char(1)), d.rolename 
from sysibm.sysauditpolicies a, sysibm.sysroles d 
where d.auditpolicyid is not null 
and a.auditpolicyid = d.auditpolicyid 
union all 
select a.auditpolicyname, a.auditpolicyid, e.type, 
cast(' ' as char(1)), e.creator, e.name 
from sysibm.sysauditpolicies a, sysibm.systables e 
where e.auditpolicyid is not null 
and a.auditpolicyid = e.auditpolicyid;

CREATE VIEW "SYSCAT"."BUFFERPOOLDBPARTITIONS" ("BUFFERPOOLID", "DBPARTITIONNUM", "NPAGES") AS
select 
bufferpoolid, nodenum, npages 
from sysibm.sysbufferpoolnodes;

CREATE VIEW "SYSCAT"."BUFFERPOOLNODES" ("BUFFERPOOLID", "NODENUM", "NPAGES") AS
select 
bufferpoolid, nodenum, npages 
from sysibm.sysbufferpoolnodes;

CREATE VIEW "SYSCAT"."BUFFERPOOLS" ("BPNAME", "BUFFERPOOLID", "DBPGNAME", "NPAGES", "PAGESIZE", "ESTORE", "NUMBLOCKPAGES", "BLOCKSIZE", "NGNAME") AS
select 
bpname, bufferpoolid, ngname, npages, pagesize, cast('N' as char(1)), 
numblockpages, blocksize, ngname 
from sysibm.sysbufferpools;

CREATE VIEW "SYSCAT"."CASTFUNCTIONS" ("FROM_TYPESCHEMA", "FROM_TYPEMODULENAME", "FROM_TYPENAME", "FROM_TYPEMODULEID", "TO_TYPESCHEMA", "TO_TYPEMODULENAME", "TO_TYPENAME", "TO_TYPEMODULEID", "FUNCSCHEMA", "FUNCMODULENAME", "FUNCNAME", "SPECIFICNAME", "FUNCMODULEID", "ASSIGN_FUNCTION") AS
select 
p1.typeschema, m1.modulename, p1.typename, p1.typemoduleid, 
p2.typeschema, m2.modulename, p2.typename, p2.typemoduleid, 
f.routineschema, m.modulename, f.routinename, f.specificname, 
f.routinemoduleid, f.assign_function 
from 
(sysibm.sysroutines as f left outer join sysibm.sysmodules m on 
f.routinemoduleid = m.moduleid), 
(sysibm.sysroutineparms as p1 left outer join sysibm.sysmodules m1 on 
p1.typemoduleid = m1.moduleid), 
(sysibm.sysroutineparms as p2 left outer join sysibm.sysmodules m2 on 
p2.typemoduleid = m2.moduleid) 
where 
f.cast_function = 'Y' 
and f.routine_id = p1.routine_id 
and f.routine_id = p2.routine_id 
and f.routinetype in ('F', 'M') 
and f.routineschema not in ('SYSIBMINTERNAL') 
and p1.rowtype = 'P' 
and p1.ordinal = 1 
and p2.rowtype = 'C' 
and p2.ordinal = 0;

CREATE VIEW "SYSCAT"."CHECKS" ("CONSTNAME", "OWNER", "OWNERTYPE", "TABSCHEMA", "TABNAME", "CREATE_TIME", "QUALIFIER", "TYPE", "FUNC_PATH", "TEXT", "PERCENTVALID", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "DEFINER") AS
select 
name, definer, definertype, tbcreator, tbname, create_time, 
qualifier, type,  func_path, text, percentvalid, 
coalesce(c1.collationschema, 'SYSIBM'), 
coalesce(c1.collationname, syscat.collationname(x.collationid)), 
coalesce(c2.collationschema, 'SYSIBM'), 
coalesce(c2.collationname, syscat.collationname(x.collationid_orderby)), 
definer 
from sysibm.syschecks x 
left outer join sysibm.syscollations as c1 
on x.collationid = c1.collationid 
left outer join sysibm.syscollations as c2 
on x.collationid_orderby = c2.collationid;

CREATE VIEW "SYSCAT"."COLAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "TABSCHEMA", "TABNAME", "COLNAME", "COLNO", "PRIVTYPE", "GRANTABLE") AS
select 
grantor, grantortype, grantee, granteetype, creator, tname, colname, 
colno, privtype, grantable 
from sysibm.syscolauth;

CREATE VIEW "SYSCAT"."COLCHECKS" ("CONSTNAME", "TABSCHEMA", "TABNAME", "COLNAME", "USAGE") AS
select 
constname,tbcreator, tbname, colname, usage 
from sysibm.syscolchecks;

CREATE VIEW "SYSCAT"."COLDIST" ("TABSCHEMA", "TABNAME", "COLNAME", "TYPE", "SEQNO", "COLVALUE", "VALCOUNT", "DISTCOUNT") AS
select 
schema, tbname, name, type, seqno, colvalue, 
valcount, distcount 
from sysibm.syscoldist;

CREATE VIEW "SYSCAT"."COLGROUPCOLS" ("COLGROUPID", "COLNAME", "TABSCHEMA", "TABNAME", "ORDINAL") AS
select 
colgroupid, colname, tabschema, tabname, ordinal 
from sysibm.syscolgroupscols;

CREATE VIEW "SYSCAT"."COLGROUPDIST" ("COLGROUPID", "TYPE", "ORDINAL", "SEQNO", "COLVALUE") AS
select 
colgroupid, type, ordinal, seqno, colvalue 
from sysibm.syscolgroupdist;

CREATE VIEW "SYSCAT"."COLGROUPDISTCOUNTS" ("COLGROUPID", "TYPE", "SEQNO", "VALCOUNT", "DISTCOUNT") AS
select 
colgroupid, type, seqno, valcount, distcount 
from sysibm.syscolgroupdistcounts;

CREATE VIEW "SYSCAT"."COLGROUPS" ("COLGROUPSCHEMA", "COLGROUPNAME", "COLGROUPID", "COLGROUPCARD", "NUMFREQ_VALUES", "NUMQUANTILES") AS
select 
colgroupschema, colgroupname, colgroupid, colgroupcard, 
numfreq_values, numquantiles 
from sysibm.syscolgroups;

CREATE VIEW "SYSCAT"."COLIDENTATTRIBUTES" ("TABSCHEMA", "TABNAME", "COLNAME", "START", "INCREMENT", "MINVALUE", "MAXVALUE", "CYCLE", "CACHE", "ORDER", "NEXTCACHEFIRSTVALUE", "SEQID") AS
select 
c.tbcreator, c.tbname, c.name, s.start, 
s.increment, s.minvalue, s.maxvalue, s.cycle, 
s.cache, s.order, 
case when s.lastassignedval + s.increment > s.maxvalue 
and s.increment > 0 
then case when s.cycle = 'Y' then s.minvalue else null end 
when s.lastassignedval + s.increment < s.minvalue 
and s.increment < 0 
then case when s.cycle = 'Y' then s.maxvalue else null end 
else coalesce(s.lastassignedval + s.increment, s.start) end, 
s.seqid 
from sysibm.syscolumns as c, sysibm.sysdependencies as d, 
sysibm.syssequences as s 
where c.tbcreator = d.dschema and 
c.tbname = d.dname and 
d.bname = s.seqname and 
d.bschema = s.seqschema and 
c.identity = 'Y' and 
d.dtype = 'T' and 
d.btype = 'Q' and 
s.seqtype = 'I';

CREATE VIEW "SYSCAT"."COLLATIONS" ("COLLATIONSCHEMA", "COLLATIONNAME", "SOURCECOLLATIONSCHEMA", "SOURCECOLLATIONNAME", "OWNER", "OWNERTYPE", "REMARKS") AS
select 
c.collationschema, c.collationname, 
cast('SYSIBM' as VARCHAR(128)), 
syscat.collationname(c.sourcecollationid), 
c.owner, c.ownertype, cmnt.remarks 
from sysibm.syscollations c left outer join sysibm.syscomments cmnt 
on cmnt.objecttype='c' and c.objectid = cmnt.objectid;

CREATE VIEW "SYSCAT"."COLOPTIONS" ("TABSCHEMA", "TABNAME", "COLNAME", "OPTION", "SETTING") AS
select 
tabschema, tabname, colname, option, setting 
from sysibm.syscoloptions;

CREATE VIEW "SYSCAT"."COLUMNS" ("TABSCHEMA", "TABNAME", "COLNAME", "COLNO", "TYPESCHEMA", "TYPENAME", "LENGTH", "SCALE", "DEFAULT", "NULLS", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "LOGGED", "COMPACT", "COLCARD", "HIGH2KEY", "LOW2KEY", "AVGCOLLEN", "KEYSEQ", "PARTKEYSEQ", "NQUANTILES", "NMOSTFREQ", "NUMNULLS", "TARGET_TYPESCHEMA", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME", "SOURCE_TABSCHEMA", "SOURCE_TABNAME", "DL_FEATURES", "SPECIAL_PROPS", "HIDDEN", "INLINE_LENGTH", "PCTINLINED", "IDENTITY", "ROWCHANGETIMESTAMP", "GENERATED", "TEXT", "COMPRESS", "AVGDISTINCTPERPAGE", "PAGEVARIANCERATIO", "SUB_COUNT", "SUB_DELIM_LENGTH", "AVGCOLLENCHAR", "IMPLICITVALUE", "SECLABELNAME", "REMARKS") AS
select 
c.tbcreator, c.tbname, c.name, c.colno, c.typeschema, 
c.typename, c.longlength, c.scale, c.default, c.nulls, 
c.composite_codepage, 
case when c.collationid is null then null 
else coalesce((select col.collationschema from sysibm.syscollations col 
where c.collationid = col.collationid), 
'SYSIBM') end, 
case when c.collationid is null then null 
else coalesce((select col.collationname from sysibm.syscollations col 
where c.collationid = col.collationid), 
syscat.collationname(c.collationid)) end, 
c.logged, c.compact, c.colcard, 
c.high2key, c.low2key, c.avgcollen, 
c.keyseq, c.partkeyseq, c.nquantiles, c.nmostfreq, 
c.numnulls, 
(select p.target_typeschema 
from sysibm.syscolproperties p 
where c.tbcreator = p.tabschema 
and c.tbname = p.tabname 
and c.name = p.colname), 
(select p.target_typename 
from sysibm.syscolproperties p 
where c.tbcreator = p.tabschema 
and c.tbname = p.tabname 
and c.name = p.colname), 
(select p.scope_tabschema 
from sysibm.syscolproperties p 
where c.tbcreator = p.tabschema 
and c.tbname = p.tabname 
and c.name = p.colname), 
(select p.scope_tabname 
from sysibm.syscolproperties p 
where c.tbcreator = p.tabschema 
and c.tbname = p.tabname 
and c.name = p.colname), 
c.source_tabschema, c.source_tabname, 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.ATTRIBUTES.DL_FEATURES'), 
cast (null as char(10))), 
case 
when c.coltype = 'REF' then 
(select p.special_props 
from sysibm.syscolproperties p 
where c.tbcreator = p.tabschema 
and c.tbname = p.tabname 
and c.name = p.colname) 
else null 
end, 
c.hidden, c.inline_length, c.pctinlined, 
case when c.identity = 'Y' then cast('Y' as char(1)) 
else cast('N' as char(1)) end, 
case when c.identity = 'T' then cast('Y' as char(1)) 
else cast('N' as char(1)) end, 
c.generated, 
case 
when c.generated = ' ' then null 
else 
(select case 
when posstr(ch.text, ' =  ') = 0 
then ch.text 
else 'AS' concat 
substr(ch.text, 
posstr(ch.text, ' =  ') + 3) 
end 
from sysibm.syschecks ch, sysibm.syscolchecks cc 
where c.tbcreator = cc.tbcreator 
and c.tbname = cc.tbname 
and c.name = cc.colname 
and cc.usage = 'T' 
and cc.constname = ch.name 
and cc.tbcreator = ch.tbcreator 
and cc.tbname = ch.tbname) 
end, 
c.compress, c.avgdistinctperpage, c.pagevarianceratio, 
c.sub_count, c.sub_delim_length, c.avgcollenchar, c.implicitvalue, 
(select seclabelname 
from sysibm.syssecuritylabels where seclabelid = c.seclabelid), 
c.remarks 
from sysibm.syscolumns c;

CREATE VIEW "SYSCAT"."COLUSE" ("TABSCHEMA", "TABNAME", "COLNAME", "DIMENSION", "COLSEQ", "TYPE") AS
select 
tabschema, tabname, colname, dimension, colseq, type 
from sysibm.syscoluse;

CREATE VIEW "SYSCAT"."CONDITIONS" ("CONDSCHEMA", "CONDMODULENAME", "CONDNAME", "CONDID", "CONDMODULEID", "SQLSTATE", "OWNER", "OWNERTYPE", "CREATE_TIME", "REMARKS") AS
select 
v.varschema, m.modulename, v.varname, v.varid, v.varmoduleid, 
CAST(substr(v.default,2,5) AS CHAR(5)), v.owner, v.ownertype, 
v.create_time, c.remarks 
from 
sysibm.sysvariables as v 
left outer join sysibm.sysdatatypes as d on v.typeid = d.typeid 
left outer join sysibm.sysmodules as m on v.varmoduleid = m.moduleid 
left outer join sysibm.syscomments as c 
on v.varid = c.objectid and c.objecttype = 'v' 
where d.schema = 'SYSPROC' and d.name = 'DB2SQLSTATE';

CREATE VIEW "SYSCAT"."CONSTDEP" ("CONSTNAME", "TABSCHEMA", "TABNAME", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID") AS
select 
dconstname, dtbcreator, dtbname, btype, bcreator, m.modulename, bname, bmoduleid 
from sysibm.sysconstdep left outer join sysibm.sysmodules m on bmoduleid=m.moduleid;

CREATE VIEW "SYSCAT"."CONTEXTATTRIBUTES" ("CONTEXTNAME", "ATTR_NAME", "ATTR_VALUE", "ATTR_OPTIONS") AS
select 
b.contextname, a.attr_name, a.attr_value, a.attr_options 
from sysibm.syscontextattributes a, sysibm.syscontexts b 
where a.contextid = b.contextid;

CREATE VIEW "SYSCAT"."CONTEXTS" ("CONTEXTNAME", "CONTEXTID", "SYSTEMAUTHID", "DEFAULTCONTEXTROLE", "CREATE_TIME", "ALTER_TIME", "ENABLED", "AUDITPOLICYID", "AUDITPOLICYNAME", "REMARKS") AS
select 
a.contextname , a.contextid, a.systemauthid,a.defaultcontextrole, 
a.create_time, a.alter_time, a.enabled, a.auditpolicyid, 
case when a.auditpolicyid is null then null 
else (select auditpolicyname from sysibm.sysauditpolicies aud 
where a.auditpolicyid = aud.auditpolicyid) 
end, 
b.remarks 
from sysibm.syscontexts a left outer join sysibm.syscomments b 
on a.contextid = b.objectid and b.objecttype = 'x';

CREATE VIEW "SYSCAT"."DATAPARTITIONEXPRESSION" ("TABSCHEMA", "TABNAME", "DATAPARTITIONKEYSEQ", "DATAPARTITIONEXPRESSION", "NULLSFIRST") AS
select 
tabschema, tabname, datapartitionkeyseq, datapartitionexpression, 
nullsfirst 
from sysibm.sysdatapartitionexpression;

CREATE VIEW "SYSCAT"."DATAPARTITIONS" ("DATAPARTITIONNAME", "TABSCHEMA", "TABNAME", "DATAPARTITIONID", "TBSPACEID", "PARTITIONOBJECTID", "LONG_TBSPACEID", "ACCESS_MODE", "STATUS", "SEQNO", "LOWINCLUSIVE", "LOWVALUE", "HIGHINCLUSIVE", "HIGHVALUE", "CARD", "OVERFLOW", "NPAGES", "FPAGES", "ACTIVE_BLOCKS", "INDEX_TBSPACEID", "AVGROWSIZE", "PCTROWSCOMPRESSED", "PCTPAGESAVED", "AVGCOMPRESSEDROWSIZE", "AVGROWCOMPRESSIONRATIO", "STATS_TIME", "LASTUSED") AS
select 
datapartitionname, tabschema, tabname, datapartitionid, 
tbspaceid, partitionobjectid, long_tbspaceid, 
access_mode, status, seqno, 
lowinclusive, lowvalue, highinclusive, highvalue, 
card, overflow, npages, fpages, active_blocks, 
index_tbspaceid, avgrowsize, pctrowscompressed, 
pctpagesaved, avgcompressedrowsize, avgrowcompressionratio, 
stats_time, lastused 
from sysibm.sysdatapartitions;

CREATE VIEW "SYSCAT"."DATATYPEDEP" ("TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "TYPEMODULEID", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, md.modulename, dname, dmoduleid, 
btype, bschema, mb.modulename, bname, bmoduleid, tabauth 
from 
sysibm.sysdependencies 
left outer join sysibm.sysmodules md on dmoduleid=md.moduleid 
left outer join sysibm.sysmodules mb on bmoduleid=mb.moduleid 
where dtype = 'R';

CREATE VIEW "SYSCAT"."DATATYPES" ("TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "OWNER", "OWNERTYPE", "SOURCESCHEMA", "SOURCEMODULENAME", "SOURCENAME", "METATYPE", "TYPEID", "TYPEMODULEID", "SOURCETYPEID", "SOURCEMODULEID", "PUBLISHED", "LENGTH", "SCALE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "ARRAY_LENGTH", "ARRAYINDEXTYPESCHEMA", "ARRAYINDEXTYPENAME", "ARRAYINDEXTYPEID", "ARRAYINDEXTYPELENGTH", "CREATE_TIME", "VALID", "ATTRCOUNT", "INSTANTIABLE", "WITH_FUNC_ACCESS", "FINAL", "INLINE_LENGTH", "NATURAL_INLINE_LENGTH", "JARSCHEMA", "JAR_ID", "CLASS", "SQLJ_REPRESENTATION", "ALTER_TIME", "DEFINER", "REMARKS") AS
select 
d.schema, m.modulename, d.name, d.definer, d.definertype, 
d.sourceschema, m2.modulename, d.sourcetype, 
d.metatype, d.typeid, d.typemoduleid, d.sourcetypeid, d.sourcemoduleid, 
d.published, d.length, d.scale, d.codepage, 
case when d.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when d.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(d.collationid)) end, 
case when d.metatype='A' then d.array_length else null end, 
case when d.metatype='L' then cast('SYSIBM' as varchar(128)) else null end, 
case when d.metatype='L' then 
(select dd.name from sysibm.sysdatatypes dd 
where dd.typeid = d.arrayindextypeid) else null end, 
d.arrayindextypeid, 
case when d.metatype='L' then d.array_length else null end, 
d.create_time, d.valid, d.attrcount, d.instantiable, 
d.with_func_access, d.final, d.inline_length, d.natural_inline_length, 
d.jarschema, d.jar_id, d.class, d.sqlj_representation, 
d.alter_time, d.definer, d.remarks 
from sysibm.sysdatatypes as d left outer join sysibm.syscollations as c 
on d.collationid = c.collationid 
left outer join sysibm.sysmodules m on d.typemoduleid=m.moduleid 
left outer join sysibm.sysmodules m2 on d.sourcemoduleid = m2.moduleid;

CREATE VIEW "SYSCAT"."DBAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "BINDADDAUTH", "CONNECTAUTH", "CREATETABAUTH", "DBADMAUTH", "EXTERNALROUTINEAUTH", "IMPLSCHEMAAUTH", "LOADAUTH", "NOFENCEAUTH", "QUIESCECONNECTAUTH", "LIBRARYADMAUTH", "SECURITYADMAUTH", "SQLADMAUTH", "WLMADMAUTH", "EXPLAINAUTH", "DATAACCESSAUTH", "ACCESSCTRLAUTH") AS
select 
grantor, grantortype, grantee, granteetype, 
bindaddauth, connectauth, createtabauth, dbadmauth, 
externalroutineauth, implschemaauth, loadauth, 
nofenceauth, quiesceconnectauth, libraryadmauth, securityadmauth, 
sqladmauth, wlmadmauth, explainauth, dataaccessauth, accessctrlauth 
from sysibm.sysdbauth;

CREATE VIEW "SYSCAT"."DBPARTITIONGROUPDEF" ("DBPGNAME", "DBPARTITIONNUM", "IN_USE") AS
select 
ngname, nodenum, in_use 
from sysibm.sysnodegroupdef;

CREATE VIEW "SYSCAT"."DBPARTITIONGROUPS" ("DBPGNAME", "OWNER", "OWNERTYPE", "PMAP_ID", "REDISTRIBUTE_PMAP_ID", "CREATE_TIME", "DEFINER", "REMARKS") AS
select 
name, definer, definertype, pmap_id, rebalance_pmap_id, ctime, 
definer, remarks 
from sysibm.sysnodegroups;

CREATE VIEW "SYSCAT"."EVENTMONITORS" ("EVMONNAME", "OWNER", "OWNERTYPE", "TARGET_TYPE", "TARGET", "MAXFILES", "MAXFILESIZE", "BUFFERSIZE", "IO_MODE", "WRITE_MODE", "AUTOSTART", "DBPARTITIONNUM", "MONSCOPE", "EVMON_ACTIVATES", "NODENUM", "DEFINER", "REMARKS") AS
select 
name, definer, definertype, target_type, target, maxfiles, 
maxfilesize, buffersize, io_mode, write_mode, autostart, 
nodenum, monscope, evmon_activates, nodenum, 
definer, remarks 
from sysibm.syseventmonitors;

CREATE VIEW "SYSCAT"."EVENTS" ("EVMONNAME", "TYPE", "FILTER") AS
select 
name, type, filter 
from sysibm.sysevents;

CREATE VIEW "SYSCAT"."EVENTTABLES" ("EVMONNAME", "LOGICAL_GROUP", "TABSCHEMA", "TABNAME", "PCTDEACTIVATE") AS
select 
evmonname, logical_group, tabschema, tabname, pctdeactivate 
from sysibm.syseventtables;

CREATE VIEW "SYSCAT"."FULLHIERARCHIES" ("METATYPE", "SUB_SCHEMA", "SUB_NAME", "SUPER_SCHEMA", "SUPER_NAME", "ROOT_SCHEMA", "ROOT_NAME") AS
(select metatype, sub_schema, sub_name, 
super_schema, super_name, 
root_schema, root_name 
from sysibm.syshierarchies) 
union all 
(select h.metatype, h.sub_schema, h.sub_name, 
f.super_schema, f.super_name, 
h.root_schema, h.root_name 
from syscat.fullhierarchies as f, 
sysibm.syshierarchies as h 
where f.sub_schema = h.super_schema 
and f.sub_name = h.super_name);

CREATE VIEW "SYSCAT"."FUNCDEP" ("FUNCSCHEMA", "FUNCMODULENAME", "FUNCNAME", "FUNCMODULEID", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, md.modulename, dname, dmoduleid, btype, bschema, 
mb.modulename, bname, bmoduleid, tabauth 
from sysibm.sysdependencies 
left outer join sysibm.sysmodules md on dmoduleid=md.moduleid 
left outer join sysibm.sysmodules mb on bmoduleid=mb.moduleid 
where dtype = 'F';

CREATE VIEW "SYSCAT"."FUNCMAPOPTIONS" ("FUNCTION_MAPPING", "OPTION", "SETTING") AS
select 
function_mapping, option, setting 
from sysibm.sysfuncmapoptions;

CREATE VIEW "SYSCAT"."FUNCMAPPARMOPTIONS" ("FUNCTION_MAPPING", "ORDINAL", "LOCATION", "OPTION", "SETTING") AS
select 
function_mapping, ordinal, location, option, setting 
from sysibm.sysfuncmapparmoptions;

CREATE VIEW "SYSCAT"."FUNCMAPPINGS" ("FUNCTION_MAPPING", "FUNCSCHEMA", "FUNCNAME", "FUNCID", "SPECIFICNAME", "OWNER", "OWNERTYPE", "WRAPNAME", "SERVERNAME", "SERVERTYPE", "SERVERVERSION", "CREATE_TIME", "DEFINER", "REMARKS") AS
select 
function_mapping, funcschema, funcname, funcid, 
specificname, definer, definertype, wrapname, servername, servertype, 
serverversion, create_time, definer, remarks 
from sysibm.sysfuncmappings;

CREATE VIEW "SYSCAT"."FUNCPARMS" ("FUNCSCHEMA", "FUNCNAME", "SPECIFICNAME", "ROWTYPE", "ORDINAL", "PARMNAME", "TYPESCHEMA", "TYPENAME", "LENGTH", "SCALE", "CODEPAGE", "CAST_FUNCID", "AS_LOCATOR", "TARGET_TYPESCHEMA", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME", "TRANSFORM_GRPNAME") AS
select 
routineschema, routinename, specificname, rowtype, ordinal, 
parmname, typeschema, typename, length, scale, codepage, 
cast_function_id, locator, target_typeschema, 
target_typename, scope_tabschema, scope_tabname, 
transform_grpname 
from sysibm.sysroutineparms 
where routinetype in ('F', 'M') 
and routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."FUNCTIONS" ("FUNCSCHEMA", "FUNCNAME", "SPECIFICNAME", "DEFINER", "FUNCID", "RETURN_TYPE", "ORIGIN", "TYPE", "METHOD", "EFFECT", "PARM_COUNT", "PARM_SIGNATURE", "CREATE_TIME", "QUALIFIER", "WITH_FUNC_ACCESS", "TYPE_PRESERVING", "VARIANT", "SIDE_EFFECTS", "FENCED", "NULLCALL", "CAST_FUNCTION", "ASSIGN_FUNCTION", "SCRATCHPAD", "FINAL_CALL", "PARALLELIZABLE", "CONTAINS_SQL", "DBINFO", "RESULT_COLS", "LANGUAGE", "IMPLEMENTATION", "CLASS", "JAR_ID", "PARM_STYLE", "SOURCE_SCHEMA", "SOURCE_SPECIFIC", "IOS_PER_INVOC", "INSTS_PER_INVOC", "IOS_PER_ARGBYTE", "INSTS_PER_ARGBYTE", "PERCENT_ARGBYTES", "INITIAL_IOS", "INITIAL_INSTS", "CARDINALITY", "IMPLEMENTED", "SELECTIVITY", "OVERRIDDEN_FUNCID", "SUBJECT_TYPESCHEMA", "SUBJECT_TYPENAME", "FUNC_PATH", "BODY", "REMARKS") AS
select 
a.routineschema, a.routinename, a.specificname, a.definer, a.routine_id, 
a.return_type, a.origin, a.function_type, 
CAST (CASE a.routinetype 
WHEN 'M' THEN 'Y' 
ELSE 'N' END AS CHAR(1)), 
a.methodeffect, a.parm_count, 
a.parm_signature, a.createdts, a.qualifier, a.with_func_access, 
CAST (CASE 
WHEN a.type_preserving = 'Y' 
THEN 'Y' 
ELSE 'N' 
END AS CHAR(1)), 
CAST (CASE a.deterministic 
WHEN 'Y' THEN 'N' 
WHEN 'N' THEN 'Y' 
ELSE ' ' END AS CHAR(1)), 
a.external_action, a.fenced, a.null_call, 
a.cast_function, a.assign_function, a.scratchpad, 
a.final_call, a.parallel, a.sql_data_access, a.dbinfo, a.result_cols, 
a.language, a.implementation, 
(SELECT pj.class FROM 
SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id), 
(SELECT pj.jar_id FROM 
SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id), 
a.parameter_style, a.sourceschema, a.sourcespecific, a.ios_per_invoc, 
a.insts_per_invoc, a.ios_per_argbyte, a.insts_per_argbyte, 
a.percent_argbytes, a.initial_ios, a.initial_insts, a.cardinality, 
a.methodimplemented, a.selectivity, a.overridden_methodid, 
a.subject_typeschema, a.subject_typename, a.func_path, a.text, 
a.remarks 
from sysibm.sysroutines as a 
where a.routinetype in ('F', 'M') 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."HIERARCHIES" ("METATYPE", "SUB_SCHEMA", "SUB_NAME", "SUPER_SCHEMA", "SUPER_NAME", "ROOT_SCHEMA", "ROOT_NAME") AS
select 
metatype, sub_schema, sub_name, super_schema, 
super_name, root_schema, root_name 
from sysibm.syshierarchies;

CREATE VIEW "SYSCAT"."HISTOGRAMTEMPLATEBINS" ("TEMPLATENAME", "TEMPLATEID", "BINID", "BINUPPERVALUE") AS
select 
a.templatename, b.templateid, b.binid, b.binuppervalue 
from sysibm.syshistogramtemplatebins as b left outer join 
sysibm.syshistogramtemplates as a 
on b.templateid = a.templateid;

CREATE VIEW "SYSCAT"."HISTOGRAMTEMPLATES" ("TEMPLATEID", "TEMPLATENAME", "CREATE_TIME", "ALTER_TIME", "NUMBINS", "REMARKS") AS
select 
a.templateid, a.templatename, a.create_time, a.alter_time, 
a.numbins, b.remarks 
from sysibm.syshistogramtemplates as a left outer join 
sysibm.syscomments as b 
on b.objectid = a.templateid and b.objecttype = 'h';

CREATE VIEW "SYSCAT"."HISTOGRAMTEMPLATEUSE" ("TEMPLATENAME", "TEMPLATEID", "HISTOGRAMTYPE", "OBJECTTYPE", "OBJECTID", "SERVICECLASSNAME", "PARENTSERVICECLASSNAME", "WORKACTIONNAME", "WORKACTIONSETNAME", "WORKLOADNAME") AS
select 
a.templatename, b.templateid, b.histogramtype, 
b.objecttype, b.objectid, 
case when b.objecttype in 'b' then 
c.serviceclassname 
else 
cast(null as varchar(128)) end, 
case when b.objecttype in 'b' then 
d.serviceclassname 
else 
cast(null as varchar(128)) end, 
case when b.objecttype in 'k' then 
e.actionname 
else 
cast(null as varchar(128)) end, 
case when b.objecttype in 'k' then 
f.actionsetname 
else 
cast(null as varchar(128)) end, 
case when b.objecttype in 'w' then 
g.workloadname 
else 
cast(null as varchar(128)) end 
from sysibm.syshistogramtemplateuse as b 
left outer join sysibm.syshistogramtemplates as a 
on b.templateid = a.templateid 
left outer join sysibm.sysserviceclasses as c 
on c.serviceclassid = b.objectid 
left outer join sysibm.sysserviceclasses as d 
on c.parentid = d.serviceclassid 
left outer join sysibm.sysworkactions as e 
on e.actionid = b.objectid 
left outer join sysibm.sysworkactionsets as f 
on e.actionsetid = f.actionsetid 
left outer join sysibm.sysworkloads as g 
on g.workloadid = b.objectid;

CREATE VIEW "SYSCAT"."INDEXAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "INDSCHEMA", "INDNAME", "CONTROLAUTH") AS
select 
grantor, grantortype, grantee, granteetype, creator, name, 
controlauth 
from sysibm.sysindexauth;

CREATE VIEW "SYSCAT"."INDEXCOLUSE" ("INDSCHEMA", "INDNAME", "COLNAME", "COLSEQ", "COLORDER", "COLLATIONSCHEMA", "COLLATIONNAME") AS
select 
indschema, indname, colname, colseq, colorder, 
case when i.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when i.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(i.collationid)) end 
from sysibm.sysindexcoluse as i left outer join sysibm.syscollations as c 
on i.collationid = c.collationid;

CREATE VIEW "SYSCAT"."INDEXDEP" ("INDSCHEMA", "INDNAME", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, dname, btype, bschema, m.modulename, bname, bmoduleid, tabauth 
from sysibm.sysdependencies 
left outer join sysibm.sysmodules m on bmoduleid=m.moduleid 
where dtype = 'I';

CREATE VIEW "SYSCAT"."INDEXES" ("INDSCHEMA", "INDNAME", "OWNER", "OWNERTYPE", "TABSCHEMA", "TABNAME", "COLNAMES", "UNIQUERULE", "MADE_UNIQUE", "COLCOUNT", "UNIQUE_COLCOUNT", "INDEXTYPE", "ENTRYTYPE", "PCTFREE", "IID", "NLEAF", "NLEVELS", "FIRSTKEYCARD", "FIRST2KEYCARD", "FIRST3KEYCARD", "FIRST4KEYCARD", "FULLKEYCARD", "CLUSTERRATIO", "CLUSTERFACTOR", "SEQUENTIAL_PAGES", "DENSITY", "USER_DEFINED", "SYSTEM_REQUIRED", "CREATE_TIME", "STATS_TIME", "PAGE_FETCH_PAIRS", "MINPCTUSED", "REVERSE_SCANS", "INTERNAL_FORMAT", "COMPRESSION", "IESCHEMA", "IENAME", "IEARGUMENTS", "INDEX_OBJECTID", "NUMRIDS", "NUMRIDS_DELETED", "NUM_EMPTY_LEAFS", "AVERAGE_RANDOM_FETCH_PAGES", "AVERAGE_RANDOM_PAGES", "AVERAGE_SEQUENCE_GAP", "AVERAGE_SEQUENCE_FETCH_GAP", "AVERAGE_SEQUENCE_PAGES", "AVERAGE_SEQUENCE_FETCH_PAGES", "TBSPACEID", "LEVEL2PCTFREE", "PAGESPLIT", "AVGPARTITION_CLUSTERRATIO", "AVGPARTITION_CLUSTERFACTOR", "AVGPARTITION_PAGE_FETCH_PAIRS", "PCTPAGESSAVED", "DATAPARTITION_CLUSTERFACTOR", "INDCARD", "AVGLEAFKEYSIZE", "AVGNLEAFKEYSIZE", "OS_PTR_SIZE", "COLLECTSTATISTCS", "DEFINER", "LASTUSED", "REMARKS") AS
select 
creator, name, definer, definertype, tbcreator, tbname, 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.INDEXES.COLNAMES'), 
colnames), 
uniquerule, made_unique, colcount, 
unique_colcount,indextype, entrytype, pctfree, 
iid, nleaf, nlevels, 
firstkeycard, first2keycard, first3keycard, first4keycard, 
fullkeycard, clusterratio, clusterfactor, sequential_pages, 
density, user_defined, system_required, create_time, 
stats_time, page_fetch_pairs, minpctused, reverse_scans, 
internal_format, compression, 
ieschema, iename, iearguments, index_objectid, 
numrids, numrids_deleted, num_empty_leafs, 
average_random_fetch_pages, average_random_pages, 
average_sequence_gap, average_sequence_fetch_gap, 
average_sequence_pages, average_sequence_fetch_pages, 
tbspaceid, level2pctfree, pagesplit, 
avgpartition_clusterratio, avgpartition_clusterfactor, 
avgpartition_page_fetch_pairs, pctpagessaved, 
datapartition_clusterfactor, indcard, avgleafkeysize, 
avgnleafkeysize, os_ptr_size, 
collectstatistics, definer, lastused, remarks 
from sysibm.sysindexes;

CREATE VIEW "SYSCAT"."INDEXEXPLOITRULES" ("FUNCID", "SPECID", "IESCHEMA", "IENAME", "RULEID", "SEARCHMETHODID", "SEARCHKEY", "SEARCHARGUMENT", "EXACT") AS
select 
funcid, specid, ieschema, iename, ruleid, searchmethodid, 
searchkey, searchargument, exact 
from sysibm.sysindexexploitrules;

CREATE VIEW "SYSCAT"."INDEXEXTENSIONDEP" ("IESCHEMA", "IENAME", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, dname, btype, bschema, m.modulename, bname, bmoduleid, tabauth 
from sysibm.sysdependencies 
left outer join sysibm.sysmodules m on bmoduleid=m.moduleid 
where dtype = 'X';

CREATE VIEW "SYSCAT"."INDEXEXTENSIONMETHODS" ("METHODNAME", "METHODID", "IESCHEMA", "IENAME", "RANGEFUNCSCHEMA", "RANGEFUNCNAME", "RANGESPECIFICNAME", "FILTERFUNCSCHEMA", "FILTERFUNCNAME", "FILTERSPECIFICNAME", "REMARKS") AS
select 
methodname, methodid, ieschema, iename, rtfuncschema, 
rtfuncname, rtspecificname, cwfuncschema, cwfuncname, 
cwspecificname, remarks 
from sysibm.sysindexextensionmethods;

CREATE VIEW "SYSCAT"."INDEXEXTENSIONPARMS" ("IESCHEMA", "IENAME", "ORDINAL", "PARMNAME", "TYPESCHEMA", "TYPENAME", "LENGTH", "SCALE", "PARMTYPE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME") AS
select 
i.ieschema, i.iename, i.ordinal, i.parmname, i.typeschema, i.typename, 
i.length, i.scale, i.parmtype, i.codepage, 
case when i.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when i.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(i.collationid)) end 
from sysibm.sysindexextensionparms as i 
left outer join sysibm.syscollations as c on i.collationid = c.collationid;

CREATE VIEW "SYSCAT"."INDEXEXTENSIONS" ("IESCHEMA", "IENAME", "OWNER", "OWNERTYPE", "CREATE_TIME", "KEYGENFUNCSCHEMA", "KEYGENFUNCNAME", "KEYGENSPECIFICNAME", "TEXT", "DEFINER", "REMARKS") AS
select 
ieschema, iename, definer, definertype, create_time, ktfuncschema, 
ktfuncname, ktspecificname, text, definer, remarks 
from sysibm.sysindexextensions;

CREATE VIEW "SYSCAT"."INDEXOPTIONS" ("INDSCHEMA", "INDNAME", "OPTION", "SETTING") AS
select 
indschema, indname, option, setting 
from sysibm.sysindexoptions;

CREATE VIEW "SYSCAT"."INDEXPARTITIONS" ("INDSCHEMA", "INDNAME", "TABSCHEMA", "TABNAME", "IID", "INDPARTITIONTBSPACEID", "INDPARTITIONOBJECTID", "DATAPARTITIONID", "INDCARD", "NLEAF", "NUM_EMPTY_LEAFS", "NUMRIDS", "NUMRIDS_DELETED", "FULLKEYCARD", "NLEVELS", "CLUSTERRATIO", "CLUSTERFACTOR", "FIRSTKEYCARD", "FIRST2KEYCARD", "FIRST3KEYCARD", "FIRST4KEYCARD", "AVGLEAFKEYSIZE", "AVGNLEAFKEYSIZE", "PCTFREE", "PAGE_FETCH_PAIRS", "SEQUENTIAL_PAGES", "DENSITY", "AVERAGE_SEQUENCE_GAP", "AVERAGE_SEQUENCE_FETCH_GAP", "AVERAGE_SEQUENCE_PAGES", "AVERAGE_SEQUENCE_FETCH_PAGES", "AVERAGE_RANDOM_PAGES", "AVERAGE_RANDOM_FETCH_PAGES", "STATS_TIME", "COMPRESSION", "PCTPAGESSAVED") AS
select 
indschema, indname, tabschema, tabname, iid, 
indpartitiontbspaceid, indpartitionobjectid, 
datapartitionid, indcard, nleaf, 
num_empty_leafs, numrids, numrids_deleted, 
fullkeycard, nlevels, clusterratio, clusterfactor, 
firstkeycard, first2keycard, first3keycard, 
first4keycard, avgleafkeysize, avgnleafkeysize, 
pctfree, page_fetch_pairs, sequential_pages, 
density, average_sequence_gap, average_sequence_fetch_gap, 
average_sequence_pages, average_sequence_fetch_pages, 
average_random_pages, average_random_fetch_pages, stats_time, 
compression, pctpagessaved 
from sysibm.sysindexpartitions;

CREATE VIEW "SYSCAT"."INDEXXMLPATTERNS" ("INDSCHEMA", "INDNAME", "PINDNAME", "PINDID", "TYPEMODEL", "DATATYPE", "HASHED", "LENGTH", "PATTERNID", "PATTERN") AS
select 
indschema, indname, pindname, pindid, typemodel, datatype, hashed, length, 
patternid, pattern 
from sysibm.sysindexxmlpatterns;

CREATE VIEW "SYSCAT"."INVALIDOBJECTS" ("OBJECTSCHEMA", "OBJECTMODULENAME", "OBJECTNAME", "ROUTINENAME", "OBJECTTYPE", "SQLCODE", "SQLSTATE", "ERRORMESSAGE", "LINENUMBER", "INVALIDATE_TIME", "LAST_REGEN_TIME") AS
select 
i.objectschema, m.modulename, i.objectname, 
case when i.objecttype = 'F' then r.routinename else null end, 
i.objecttype, i.sqlcode, i.sqlstate, 
cast(case when i.sqlcode is not null then 
case when i.sqlcode < 0 
then substring(SYSPROC.SQLERRM (concat('SQL', substring(varchar(i.sqlcode), 
2, octets)), i.sqlerrmc, x'FF', '', 1), 1, 4000, octets) 
else substring(SYSPROC.SQLERRM (concat('SQL', varchar(i.sqlcode)), i.sqlerrmc, 
x'FF', '', 1), 1, 4000, octets) end 
else null end as varchar(4000)), 
i.linenumber, i.invalidate_time, i.last_regen_time 
from sysibm.sysinvalidobjects i 
left outer join sysibm.sysroutines r on (i.objectname = r.specificname and 
i.objectschema = r.routineschema and (i.objectmoduleid = r.routinemoduleid or 
(i.objectmoduleid is NULL and r.routinemoduleid is NULL))) 
left outer join sysibm.sysmodules m on i.objectmoduleid = m.moduleid;

CREATE VIEW "SYSCAT"."KEYCOLUSE" ("CONSTNAME", "TABSCHEMA", "TABNAME", "COLNAME", "COLSEQ") AS
select 
constname, tbcreator, tbname, colname, colseq 
from sysibm.syskeycoluse;

CREATE VIEW "SYSCAT"."LIBRARIES" ("LIBSCHEMA", "LIBNAME", "OWNER", "OWNERTYPE", "LIB_ID", "LIBVERSION_COUNT", "ACTIVE_VERSION", "SYSTEM_REQUIRED", "DEFINER") AS
select 
libschema, libname, definer, definertype, lib_id, libversion_count, 
active_version, system_required, definer 
from sysibm.syslibraries;

CREATE VIEW "SYSCAT"."LIBRARYAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "LIBSCHEMA", "LIBNAME", "ALTERAUTH", "USAGEAUTH") AS
select 
grantor, grantortype, grantee, granteetype, libschema, libname, 
alterauth, usageauth 
from sysibm.syslibraryauth;

CREATE VIEW "SYSCAT"."LIBRARYBINDFILES" ("LIBSCHEMA", "LIBNAME", "LIBVERSION", "PACKAGE_SCHEMA", "PACKAGE_NAME", "PACKAGE_VERSION", "BINDFILE_PATH") AS
select 
l.libschema, l.libname, b.libversion, b.package_schema, 
b.package_name, b.package_version, 
b.bindfile_path 
from sysibm.syslibrarybindfiles as b, 
sysibm.syslibraries as l 
where b.lib_id = l.lib_id;

CREATE VIEW "SYSCAT"."LIBRARYVERSIONS" ("LIBSCHEMA", "LIBNAME", "LIBVERSION", "OWNER", "OWNERTYPE", "VERSIONID", "CREATE_TIME", "VERSION_PATH", "BINDFILES_COUNT", "DEFINER") AS
select 
l.libschema, l.libname, v.libversion, v.definer, v.definertype, 
'L' || digits (v.lib_id) || 'V' || digits (v.libversion), 
v.create_time, v.version_path, v.bindfiles_count, v.definer 
from sysibm.syslibraryversions as v, 
sysibm.syslibraries as l 
where v.lib_id = l.lib_id;

CREATE VIEW "SYSCAT"."MODULEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "MODULEID", "MODULESCHEMA", "MODULENAME", "EXECUTEAUTH") AS
select 
a.grantor, a.grantortype, a.grantee, a.granteetype, a.moduleid, 
m.moduleschema, m.modulename, a.executeauth 
from sysibm.sysmoduleauth a, sysibm.sysmodules m 
where a.moduleid = m.moduleid;

CREATE VIEW "SYSCAT"."MODULEOBJECTS" ("OBJECTSCHEMA", "OBJECTMODULENAME", "OBJECTNAME", "OBJECTTYPE", "PUBLISHED", "SPECIFICNAME", "USERDEFINED") AS
SELECT r.routineschema, m.modulename, r.routinename, 
cast(case r.routinetype 
when 'P' then 'PROCEDURE' 
when 'M' then 'METHOD' 
else 'FUNCTION' 
end as varchar(9)), 
r.published, r.specificname, 
cast (case r.origin 
when 'S' then 'N' 
when 'T' then 'N' 
else 'Y' 
end as char(1)) 
FROM sysibm.sysroutines as r, sysibm.sysmodules as m 
WHERE r.routinemoduleid = m.moduleid 
UNION ALL 
SELECT v.varschema, m.modulename, v.varname, 
cast('CONDITION' as varchar(9)), 
v.published, NULL, cast('Y' as char(1)) 
FROM sysibm.sysvariables as v, sysibm.sysdatatypes as d, sysibm.sysmodules as m 
WHERE v.typeid = d.typeid 
AND v.varmoduleid = m.moduleid 
AND d.schema = 'SYSPROC' and d.name = 'DB2SQLSTATE' 
UNION ALL 
SELECT v.varschema, m.modulename, v.varname, 
cast('VARIABLE' as varchar(9)), 
v.published, NULL, cast('Y' as char(1)) 
FROM sysibm.sysvariables as v,  sysibm.sysdatatypes as d, sysibm.sysmodules as m 
WHERE v.typeid = d.typeid 
AND v.varmoduleid = m.moduleid 
AND not(d.schema = 'SYSPROC' and d.name = 'DB2SQLSTATE') 
UNION ALL 
SELECT t.schema, m.modulename, t.name, 
cast('TYPE' as varchar(9)), 
t.published, NULL, cast('Y' as char(1)) 
FROM sysibm.sysdatatypes as t, sysibm.sysmodules as m 
WHERE t.typemoduleid = m.moduleid;

CREATE VIEW "SYSCAT"."MODULES" ("MODULESCHEMA", "MODULENAME", "MODULEID", "DIALECT", "OWNER", "OWNERTYPE", "MODULETYPE", "BASE_MODULESCHEMA", "BASE_MODULENAME", "CREATE_TIME", "REMARKS") AS
select 
moduleschema, modulename, moduleid, 
CAST (CASE 
WHEN moduletype = 'P' THEN 'PL/SQL' 
WHEN moduletype = 'A' THEN ' ' 
ELSE 'DB2 SQL PL' 
END AS VARCHAR(10)), 
owner, ownertype, moduletype, base_moduleschema, base_modulename, create_time, 
r.remarks 
from 
sysibm.sysmodules left outer join sysibm.syscomments r 
on moduleid = r.objectid and r.objecttype = 'm';

CREATE VIEW "SYSCAT"."NAMEMAPPINGS" ("TYPE", "LOGICAL_SCHEMA", "LOGICAL_NAME", "LOGICAL_COLNAME", "IMPL_SCHEMA", "IMPL_NAME", "IMPL_COLNAME") AS
select 
type, logical_schema, logical_name, logical_colname, 
impl_schema, impl_name, impl_colname 
from sysibm.sysnamemappings;

CREATE VIEW "SYSCAT"."NICKNAMES" ("TABSCHEMA", "TABNAME", "OWNER", "OWNERTYPE", "STATUS", "CREATE_TIME", "STATS_TIME", "COLCOUNT", "TABLEID", "TBSPACEID", "CARD", "NPAGES", "FPAGES", "OVERFLOW", "PARENTS", "CHILDREN", "SELFREFS", "KEYCOLUMNS", "KEYINDEXID", "KEYUNIQUE", "CHECKCOUNT", "DATACAPTURE", "CONST_CHECKED", "PARTITION_MODE", "STATISTICS_PROFILE", "ACCESS_MODE", "CODEPAGE", "REMOTE_TABLE", "REMOTE_SCHEMA", "SERVERNAME", "REMOTE_TYPE", "CACHINGALLOWED", "DEFINER", "REMARKS") AS
select 
creator, name, definer, definertype, status, 
ctime, stats_time, colcount, fid, 
tid, card, npages, fpages, overflow, 
parents, children, selfrefs, 
keycolumns, keyobid, keyunique, checkcount, 
data_capture, const_checked, partition_mode, 
statistics_profile, 
access_mode, codepage, 
(select cast(setting as varchar(128)) from sysibm.systaboptions 
where name = tabname and creator = tabschema and option='REMOTE_TABLE'), 
(select cast(setting as varchar(128)) from sysibm.systaboptions 
where  name = tabname and creator = tabschema and option='REMOTE_SCHEMA') , 
(select cast(setting as varchar(128)) from sysibm.systaboptions 
where name = tabname and creator = tabschema and option='SERVER'), 
(select cast(setting as char(1)) from sysibm.systaboptions 
where name = tabname and creator = tabschema and option='REMOTE_TYPE'), 
CASE substr(property,11,1)  WHEN 'Y' THEN 'N' ELSE 'Y' END, 
definer, remarks 
from sysibm.systables  where type='N';

CREATE VIEW "SYSCAT"."NODEGROUPDEF" ("NGNAME", "NODENUM", "IN_USE") AS
select 
ngname, nodenum, in_use 
from sysibm.sysnodegroupdef;

CREATE VIEW "SYSCAT"."NODEGROUPS" ("NGNAME", "OWNER", "OWNERTYPE", "PMAP_ID", "REBALANCE_PMAP_ID", "CREATE_TIME", "DEFINER", "REMARKS") AS
select 
name, definer, definertype, pmap_id, rebalance_pmap_id, ctime, 
definer, remarks 
from sysibm.sysnodegroups;

CREATE VIEW "SYSCAT"."PACKAGEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "PKGSCHEMA", "PKGNAME", "CONTROLAUTH", "BINDAUTH", "EXECUTEAUTH") AS
select 
grantor, grantortype, grantee, granteetype, creator, name, 
controlauth, bindauth, executeauth 
from sysibm.sysplanauth;

CREATE VIEW "SYSCAT"."PACKAGEDEP" ("PKGSCHEMA", "PKGNAME", "BINDER", "BINDERTYPE", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH", "VARAUTH", "UNIQUE_ID", "PKGVERSION") AS
select 
d.dcreator, d.dname, d.binder, d.bindertype, d.btype, d.bcreator, 
m.modulename, d.bname, d.bmoduleid, 
case when d.btype <> 'v' then d.tabauth else SMALLINT(0) end, 
case when d.btype = 'v' then d.tabauth else SMALLINT(0) end, d.dunique_id, 
(select p.pkgversion from sysibm.sysplan p 
where d.dcreator = p.creator 
and d.dname = p.name 
and d.dunique_id = p.unique_id) 
from sysibm.sysplandep d 
left outer join sysibm.sysmodules m on d.bmoduleid=m.moduleid;

CREATE VIEW "SYSCAT"."PACKAGES" ("PKGSCHEMA", "PKGNAME", "BOUNDBY", "BOUNDBYTYPE", "OWNER", "OWNERTYPE", "DEFAULT_SCHEMA", "VALID", "UNIQUE_ID", "TOTAL_SECT", "FORMAT", "ISOLATION", "CONCURRENTACCESSRESOLUTION", "BLOCKING", "INSERT_BUF", "LANG_LEVEL", "FUNC_PATH", "QUERYOPT", "EXPLAIN_LEVEL", "EXPLAIN_MODE", "EXPLAIN_SNAPSHOT", "SQLWARN", "SQLMATHWARN", "CREATE_TIME", "EXPLICIT_BIND_TIME", "LAST_BIND_TIME", "ALTER_TIME", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "DEGREE", "MULTINODE_PLANS", "INTRA_PARALLEL", "VALIDATE", "DYNAMICRULES", "SQLERROR", "REFRESHAGE", "FEDERATED", "TRANSFORMGROUP", "REOPTVAR", "OS_PTR_SIZE", "PKGVERSION", "STATICREADONLY", "FEDERATED_ASYNCHRONY", "ANONBLOCK", "OPTPROFILESCHEMA", "OPTPROFILENAME", "PKGID", "DBPARTITIONNUM", "DEFINER", "PKG_CREATE_TIME", "APREUSE", "EXTENDEDINDICATOR", "LASTUSED", "REMARKS") AS
select 
creator, name, boundby, boundbytype, boundby, boundbytype, default_schema, valid, 
unique_id, totalsect, format, isolation, concurrentaccessresolution, block, 
insert_buf, standards_level, func_path, queryopt, 
explain_level, explain_mode, explain_snapshot, sqlwarn, 
sqlmathwarn, pkg_create_time, explicit_bind_time, last_bind_time, alter_time, 
codepage, 
coalesce((select c1.collationschema from 
sysibm.syscollations as c1 
where p.collationid = c1.collationid), 
'SYSIBM'), 
coalesce((select c1.collationname from 
sysibm.syscollations as c1 
where p.collationid = c1.collationid), 
syscat.collationname(p.collationid)), 
coalesce((select c2.collationschema from 
sysibm.syscollations as c2 
where p.collationid_orderby = c2.collationid), 
'SYSIBM'), 
coalesce((select c2.collationname from 
sysibm.syscollations as c2 
where p.collationid_orderby = c2.collationid), 
syscat.collationname(p.collationid_orderby)), 
degree, multinode_plans, intra_parallel, validate, 
dynamicrules, sqlerror, refreshage, 
federated, transformgroup, reoptvar, 
os_ptr_size, pkgversion, 
staticreadonly, federated_asynchrony, 
anonblock, optprofileschema, optprofilename, 
pkgid, dbpartitionnum, 
boundby, pkg_create_time, apreuse, extendedindicator, lastused, remarks 
from sysibm.sysplan p;

CREATE VIEW "SYSCAT"."PARTITIONMAPS" ("PMAP_ID", "PARTITIONMAP") AS
select 
pmap_id, partitionmap 
from sysibm.syspartitionmaps 
where pmap_id <> -2;

CREATE VIEW "SYSCAT"."PASSTHRUAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "SERVERNAME") AS
select 
grantor, grantortype, grantee, granteetype, servername 
from sysibm.syspassthruauth;

CREATE VIEW "SYSCAT"."PREDICATESPECS" ("FUNCSCHEMA", "FUNCNAME", "SPECIFICNAME", "FUNCID", "SPECID", "CONTEXTOP", "CONTEXTEXP", "FILTERTEXT") AS
select 
f.routineschema, f.routinename, f.specificname, p.funcid, p.specid, 
p.contextop, p.contextexp, CAST(p.filtertext as CLOB(32K)) 
from sysibm.sysroutines as f, 
sysibm.syspredicatespecs as p 
where f.routine_id=p.funcid 
and f.routinetype in ('F', 'M') 
and f.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."PROCEDURES" ("PROCSCHEMA", "PROCNAME", "SPECIFICNAME", "PROCEDURE_ID", "DEFINER", "PARM_COUNT", "PARM_SIGNATURE", "ORIGIN", "CREATE_TIME", "DETERMINISTIC", "FENCED", "NULLCALL", "LANGUAGE", "IMPLEMENTATION", "CLASS", "JAR_ID", "PARM_STYLE", "CONTAINS_SQL", "DBINFO", "PROGRAM_TYPE", "RESULT_SETS", "VALID", "TEXT_BODY_OFFSET", "TEXT", "REMARKS") AS
select 
a.routineschema, a.routinename, a.specificname, a.routine_id, 
a.definer, a.parm_count, a.parm_signature, a.origin, a.createdts, 
a.deterministic, a.fenced, a.null_call, a.language, a.implementation, 
(select pj.class from 
sysibm.sysroutineproperties as pj 
where pj.routine_id = a.routine_id), 
(SELECT pj.jar_id FROM 
SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id), 
a.parameter_style, a.sql_data_access, a.dbinfo, 
a.program_type, a.result_sets, a.valid, a.text_body_offset, a.text, 
a.remarks 
from sysibm.sysroutines as a 
where a.routinetype in ('P') 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."PROCPARMS" ("PROCSCHEMA", "PROCNAME", "SPECIFICNAME", "SERVERNAME", "ORDINAL", "PARMNAME", "TYPESCHEMA", "TYPENAME", "TYPEID", "SOURCETYPEID", "NULLS", "LENGTH", "SCALE", "PARM_MODE", "CODEPAGE", "DBCS_CODEPAGE", "AS_LOCATOR", "TARGET_TYPESCHEMA", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME") AS
select 
routineschema, routinename, specificname, cast(null as varchar(128)), ordinal, 
parmname, typeschema, typename, typeid, 
cast(null as smallint), cast ('Y' as char(1)), 
length, scale, 
CAST (CASE rowtype 
WHEN 'P' THEN 'IN' 
WHEN 'O' THEN 'OUT' 
ELSE 'INOUT' END AS VARCHAR(5)), 
codepage, cast(null as smallint), locator, target_typeschema, target_typename, 
scope_tabschema, scope_tabname 
from sysibm.sysroutineparms 
where routinetype in ('P') 
and routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."REFERENCES" ("CONSTNAME", "TABSCHEMA", "TABNAME", "OWNER", "OWNERTYPE", "REFKEYNAME", "REFTABSCHEMA", "REFTABNAME", "COLCOUNT", "DELETERULE", "UPDATERULE", "CREATE_TIME", "FK_COLNAMES", "PK_COLNAMES", "DEFINER") AS
select 
relname, creator, tbname, definer, definertype, refkeyname, 
reftbcreator, reftbname, colcount, deleterule, updaterule, timestamp, 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.REFERENCES.FK_COLNAMES'), 
fkcolnames), 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.REFERENCES.PK_COLNAMES'), 
pkcolnames), 
definer 
from sysibm.sysrels;

CREATE VIEW "SYSCAT"."ROLEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "ROLENAME", "ROLEID", "ADMIN") AS
select 
grantor, grantortype, grantee, granteetype, rolename, roleid, admin 
from sysibm.sysroleauth;

CREATE VIEW "SYSCAT"."ROLES" ("ROLENAME", "ROLEID", "CREATE_TIME", "AUDITPOLICYID", "AUDITPOLICYNAME", "REMARKS") AS
select 
a.rolename, a.roleid, a.create_time, a.auditpolicyid, 
case when a.auditpolicyid is null then null 
else (select auditpolicyname from sysibm.sysauditpolicies aud 
where a.auditpolicyid = aud.auditpolicyid) 
end, 
b.remarks 
from sysibm.sysroles as a left outer join sysibm.syscomments as b 
on a.roleid = b.objectid and b.objecttype='r';

CREATE VIEW "SYSCAT"."ROUTINEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "SCHEMA", "SPECIFICNAME", "TYPESCHEMA", "TYPENAME", "ROUTINETYPE", "EXECUTEAUTH", "GRANT_TIME") AS
select 
grantor, grantortype, grantee, granteetype, schema, specificname, 
typeschema, typename, routinetype, executeauth, grant_time 
from sysibm.sysroutineauth 
where schema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINEDEP" ("ROUTINESCHEMA", "ROUTINEMODULENAME", "SPECIFICNAME", "ROUTINEMODULEID", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH", "ROUTINENAME") AS
select 
dschema, md.modulename, dname, dmoduleid, 
btype, bschema, mb.modulename, bname, bmoduleid, tabauth, 
coalesce(sysibm.deprecatedchar('-206', 'COLUMN', 
'SYSCAT.ROUTINEDEP.ROUTINENAME'), dname) 
from sysibm.sysdependencies 
left outer join sysibm.sysmodules md on dmoduleid=md.moduleid 
left outer join sysibm.sysmodules mb on bmoduleid=mb.moduleid 
where dtype = 'F' 
and dschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINEOPTIONS" ("ROUTINESCHEMA", "ROUTINENAME", "SPECIFICNAME", "OPTION", "SETTING") AS
select 
a.routineschema, a.routinename, a.specificname, b.option, b.setting 
from sysibm.sysroutines a , sysibm.sysroutineoptions b 
where a.routine_id = b.routineid 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINEPARMOPTIONS" ("ROUTINESCHEMA", "ROUTINENAME", "SPECIFICNAME", "ORDINAL", "OPTION", "SETTING") AS
select 
a.routineschema, a.routinename, a.specificname, b.ordinal, b.option, b.setting 
from sysibm.sysroutines a , sysibm.sysroutineparmoptions b 
where a.routine_id = b.routineid 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINEPARMS" ("ROUTINESCHEMA", "ROUTINEMODULENAME", "ROUTINENAME", "ROUTINEMODULEID", "SPECIFICNAME", "PARMNAME", "ROWTYPE", "ORDINAL", "TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "LOCATOR", "LENGTH", "SCALE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "CAST_FUNCSCHEMA", "CAST_FUNCSPECIFIC", "TARGET_TYPESCHEMA", "TARGET_TYPEMODULENAME", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME", "TRANSFORMGRPNAME", "DEFAULT", "REMARKS") AS
select 
r.routineschema, m.modulename, r.routinename, r.routinemoduleid, 
r.specificname, rp.parmname, rp.rowtype, rp.ordinal, d.schema, 
mt.modulename, d.name, rp.locator, rp.length, rp.scale, rp.codepage, 
case when rp.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when rp.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(rp.collationid)) end, 
rcast.routineschema, rcast.specificname, 
dtarget.schema, mtt.modulename, dtarget.name, rp.scope_tabschema, 
rp.scope_tabname, rp.transform_grpname, rp.default, rp.remarks 
from (((((sysibm.sysroutineparms as rp 
left outer join sysibm.sysroutines as r on rp.routine_id = r.routine_id) 
left outer join sysibm.sysdatatypes as d on rp.typeid = d.typeid) 
left outer join sysibm.sysroutines as rcast 
on rcast.routine_id = rp.cast_function_id) 
left outer join sysibm.sysdatatypes as dtarget 
on dtarget.typeid = rp.target_typeid) 
left outer join sysibm.syscollations as c 
on rp.collationid = c.collationid) 
left outer join sysibm.sysmodules m on r.routinemoduleid = m.moduleid 
left outer join sysibm.sysmodules mt on rp.typemoduleid = mt.moduleid 
left outer join sysibm.sysmodules mtt on 
rp.target_typemoduleid = mtt.moduleid 
where rp.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINES" ("ROUTINESCHEMA", "ROUTINEMODULENAME", "ROUTINENAME", "ROUTINETYPE", "OWNER", "OWNERTYPE", "SPECIFICNAME", "ROUTINEID", "ROUTINEMODULEID", "RETURN_TYPESCHEMA", "RETURN_TYPEMODULE", "RETURN_TYPENAME", "ORIGIN", "FUNCTIONTYPE", "PARM_COUNT", "LANGUAGE", "DIALECT", "SOURCESCHEMA", "SOURCESPECIFIC", "PUBLISHED", "DETERMINISTIC", "EXTERNAL_ACTION", "NULLCALL", "CAST_FUNCTION", "ASSIGN_FUNCTION", "SCRATCHPAD", "SCRATCHPAD_LENGTH", "FINALCALL", "PARALLEL", "PARAMETER_STYLE", "FENCED", "SQL_DATA_ACCESS", "DBINFO", "PROGRAMTYPE", "COMMIT_ON_RETURN", "AUTONOMOUS", "RESULT_SETS", "SPEC_REG", "FEDERATED", "THREADSAFE", "VALID", "MODULEROUTINEIMPLEMENTED", "METHODIMPLEMENTED", "METHODEFFECT", "TYPE_PRESERVING", "WITH_FUNC_ACCESS", "OVERRIDDEN_METHODID", "SUBJECT_TYPESCHEMA", "SUBJECT_TYPENAME", "CLASS", "JAR_ID", "JARSCHEMA", "JAR_SIGNATURE", "CREATE_TIME", "ALTER_TIME", "FUNC_PATH", "QUALIFIER", "IOS_PER_INVOC", "INSTS_PER_INVOC", "IOS_PER_ARGBYTE", "INSTS_PER_ARGBYTE", "PERCENT_ARGBYTES", "INITIAL_IOS", "INITIAL_INSTS", "CARDINALITY", "SELECTIVITY", "RESULT_COLS", "IMPLEMENTATION", "LIB_ID", "TEXT_BODY_OFFSET", "TEXT", "NEWSAVEPOINTLEVEL", "DEBUG_MODE", "TRACE_LEVEL", "DIAGNOSTIC_LEVEL", "CHECKOUT_USERID", "PRECOMPILE_OPTIONS", "COMPILE_OPTIONS", "EXECUTION_CONTROL", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "ENCODING_SCHEME", "LAST_REGEN_TIME", "INHERITLOCKREQUEST", "DEFINER", "REMARKS") AS
select 
a.routineschema, m.modulename, a.routinename, a.routinetype, 
a.definer, a.definertype, 
a.specificname, a.routine_id, a.routinemoduleid, 
( select schema from sysibm.sysdatatypes 
where return_type = typeid ), 
( select m1.modulename 
from sysibm.sysdatatypes d left outer join sysibm.sysmodules m1 
on d.typemoduleid = m1.moduleid 
where a.return_type = d.typeid), 
( select name from sysibm.sysdatatypes 
where return_type = typeid ), 
a.origin, a.function_type, 
a.parm_count, a.language, 
CAST (CASE 
WHEN a.dialect = '1' THEN 'DB2 SQL PL' 
WHEN a.dialect = '2' THEN 'PL/SQL' 
ELSE '' 
END AS VARCHAR(10)), 
a.sourceschema, a.sourcespecific, a.published, 
a.deterministic, a.external_action, a.null_call, a.cast_function, 
a.assign_function, a.scratchpad, a.scratchpad_length, 
a.final_call, a.parallel, a.parameter_style, a.fenced, 
a.sql_data_access, a.dbinfo, a.program_type, a.commit_on_return, a.autonomous, 
a.result_sets, a.spec_reg, a.federated, a.threadsafe, a.valid, 
case when a.routinemoduleid is not null then a.methodimplemented 
else cast(' ' as char(1)) end, 
case when a.routinemoduleid is null then a.methodimplemented 
else cast(' ' as char(1)) end, 
a.methodeffect, a.type_preserving, 
a.with_func_access, a.overridden_methodid, a.subject_typeschema, 
a.subject_typename, b.class, b.jar_id, b.jarschema, b.jar_signature, 
a.createdts, a.alteredts, a.func_path, a.qualifier, a.ios_per_invoc, 
a.insts_per_invoc, a.ios_per_argbyte, a.insts_per_argbyte, 
a.percent_argbytes, a.initial_ios, a.initial_insts, a.cardinality, 
a.selectivity, a.result_cols, a.implementation, a.lib_id, 
a.text_body_offset, a.text, a.newsavepointlevel, 
cast (case 
when a.debug_mode = '0' then 'DISALLOW' 
when a.debug_mode = '1' then 'ALLOW' 
when a.debug_mode = 'N' then 'DISABLE' 
else a.debug_mode end as varchar(8)), 
case when c.trace_level is null then '0' 
else c.trace_level end, 
case when c.diagnostic_level is null then '0' 
else c.diagnostic_level end, 
c.checkout_userid, c.precompile_options, 
c.compile_options, a.execution_control, a.codepage, 
coalesce(c1.collationschema, 'SYSIBM'), 
coalesce(c1.collationname, syscat.collationname(a.collationid)), 
coalesce(c2.collationschema, 'SYSIBM'), 
coalesce(c2.collationname, syscat.collationname(a.collationid_orderby)), 
a.encoding_scheme, a.last_regen_time, a.inheritlockrequest, 
a.definer, a.remarks 
from (sysibm.sysroutines as a 
left outer join sysibm.sysroutineproperties as b 
on a.routine_id = b.routine_id ) 
left outer join sysibm.syscodeproperties as c 
on a.routine_id = c.object_id 
and c.object_type = 'F' 
left outer join sysibm.syscollations as c1 
on a.collationid = c1.collationid 
left outer join sysibm.syscollations as c2 
on a.collationid_orderby = c2.collationid 
left outer join sysibm.sysmodules m 
on a.routinemoduleid = m.moduleid 
where a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROUTINESFEDERATED" ("ROUTINESCHEMA", "ROUTINENAME", "ROUTINETYPE", "OWNER", "OWNERTYPE", "SPECIFICNAME", "ROUTINEID", "PARM_COUNT", "DETERMINISTIC", "EXTERNAL_ACTION", "SQL_DATA_ACCESS", "COMMIT_ON_RETURN", "RESULT_SETS", "CREATE_TIME", "ALTER_TIME", "QUALIFIER", "RESULT_COLS", "CODEPAGE", "LAST_REGEN_TIME", "REMOTE_PROCEDURE", "REMOTE_SCHEMA", "SERVERNAME", "REMOTE_PACKAGE", "REMOTE_PROCEDURE_ALTER_TIME", "REMARKS") AS
select 
routineschema, routinename, routinetype, definer, definertype, 
specificname, routine_id, 
parm_count, 
deterministic, external_action, 
sql_data_access, commit_on_return, 
result_sets, 
createdts, alteredts, qualifier, 
result_cols,  codepage, 
last_regen_time, 
(select cast(setting as varchar(128)) from sysibm.sysroutineoptions 
where routine_id =routineid and option='REMOTE_PROCEDURE'), 
(select cast(setting as varchar(128)) from sysibm.sysroutineoptions 
where routine_id =routineid and option='REMOTE_SCHEMA') , 
(select cast(setting as varchar(128)) from sysibm.sysroutineoptions 
where routine_id =routineid and option='SERVER'), 
(select cast(setting as varchar(128)) from sysibm.sysroutineoptions 
where routine_id =routineid and option='REMOTE_PACKAGE'), 
(select cast(setting as varchar(128)) from sysibm.sysroutineoptions 
where routine_id =routineid and option='ALTERED_TIMESTAMP'), 
remarks 
from sysibm.sysroutines where origin ='F' 
and routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."ROWFIELDS" ("TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "FIELDNAME", "FIELDTYPESCHEMA", "FIELDTYPEMODULENAME", "FIELDTYPENAME", "ORDINAL", "LENGTH", "SCALE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME") AS
select 
a.typeschema, m.modulename, a.typename, a.attr_name, a.attr_typeschema, 
ma.modulename, a.attr_typename, 
a.ordinal, a.length, a.scale, a.codepage, 
case when a.collationid is null then null 
else coalesce(c.collationschema, 'SYSIBM') end, 
case when a.collationid is null then null 
else coalesce(c.collationname, syscat.collationname(a.collationid)) end 
from sysibm.sysattributes as a 
inner join sysibm.sysdatatypes as d on d.metatype='F' and 
a.typename = d.name and a.typeschema = d.schema and 
(a.typemoduleid = d.typemoduleid or a.typemoduleid is null and 
d.typemoduleid is null) 
left outer join sysibm.syscollations as c on a.collationid = c.collationid 
left outer join sysibm.sysmodules m  on a.typemoduleid=m.moduleid 
left outer join sysibm.sysmodules ma on a.attr_typemoduleid=ma.moduleid;

CREATE VIEW "SYSCAT"."SCHEMAAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "SCHEMANAME", "ALTERINAUTH", "CREATEINAUTH", "DROPINAUTH") AS
select 
grantor, grantortype, grantee, granteetype, schemaname, alterinauth, 
createinauth, dropinauth 
from sysibm.sysschemaauth;

CREATE VIEW "SYSCAT"."SCHEMATA" ("SCHEMANAME", "OWNER", "OWNERTYPE", "DEFINER", "DEFINERTYPE", "CREATE_TIME", "REMARKS") AS
select 
name, owner, ownertype, definer, definertype, create_time, remarks 
from sysibm.sysschemata;

CREATE VIEW "SYSCAT"."SECURITYLABELACCESS" ("GRANTOR", "GRANTEE", "GRANTEETYPE", "SECLABELID", "SECPOLICYID", "ACCESSTYPE", "GRANT_TIME") AS
select grantor, grantee, granteetype, seclabelid, 
secpolicyid, accesstype, grant_time 
from sysibm.syssecuritylabelaccess;

CREATE VIEW "SYSCAT"."SECURITYLABELCOMPONENTELEMENTS" ("COMPID", "ELEMENTVALUE", "ELEMENTVALUEENCODING", "PARENTELEMENTVALUE") AS
 select compid, elementvalue, elementvalueencoding,parentelementvalue 
from sysibm.syssecuritylabelcomponentelements;

CREATE VIEW "SYSCAT"."SECURITYLABELCOMPONENTS" ("COMPNAME", "COMPID", "COMPTYPE", "NUMELEMENTS", "CREATE_TIME", "REMARKS") AS
select 
a.compname, a.compid, a.comptype, a.numelements, a.create_time, c.remarks 
from sysibm.syssecuritylabelcomponents as a left outer join 
sysibm.syscomments as c on c.objecttype='d' and c.objectid=a.compid;

CREATE VIEW "SYSCAT"."SECURITYLABELS" ("SECLABELNAME", "SECLABELID", "SECPOLICYID", "SECLABEL", "CREATE_TIME", "REMARKS") AS
select a.seclabelname, a.seclabelid, a.secpolicyid, 
CAST (a.seclabel_internal as SYSPROC.DB2SECURITYLABEL ), 
a.create_time, c.remarks 
from  sysibm.syssecuritylabels as a left outer join sysibm.syscomments as c 
on c.objecttype='l' and c.objectid=a.seclabelid;

CREATE VIEW "SYSCAT"."SECURITYPOLICIES" ("SECPOLICYNAME", "SECPOLICYID", "NUMSECLABELCOMP", "RWSECLABELREL", "NOTAUTHWRITESECLABEL", "CREATE_TIME", "GROUPAUTHS", "ROLEAUTHS", "REMARKS") AS
select a.secpolicyname, a.secpolicyid, a.numseclabelcomp, a.rwseclabelrel, 
a.notauthwriteseclabel, a.create_time, a.groupauths, 
a.roleauths, c.remarks 
from sysibm.syssecuritypolicies as a left outer join sysibm.syscomments as c 
on c.objecttype='p' and c.objectid=a.secpolicyid;

CREATE VIEW "SYSCAT"."SECURITYPOLICYCOMPONENTRULES" ("SECPOLICYID", "COMPID", "ORDINAL", "READACCESSRULENAME", "READACCESSRULETEXT", "WRITEACCESSRULENAME", "WRITEACCESSRULETEXT") AS
select secpolicyid, compid, ordinal, readaccessrulename, 
readaccessruletext, writeaccessrulename, writeaccessruletext 
from sysibm.syssecuritypolicycomponentrules;

CREATE VIEW "SYSCAT"."SECURITYPOLICYEXEMPTIONS" ("GRANTOR", "GRANTEE", "GRANTEETYPE", "SECPOLICYID", "ACCESSRULENAME", "ACCESSTYPE", "ORDINAL", "ACTIONALLOWED", "GRANT_TIME") AS
select grantor, grantee, granteetype, secpolicyid, 
accessrulename, accesstype, ordinal, actionallowed, grant_time 
from sysibm.syssecuritypolicyexemptions;

CREATE VIEW "SYSCAT"."SEQUENCEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "SEQSCHEMA", "SEQNAME", "ALTERAUTH", "USAGEAUTH") AS
select 
a.grantor, a.grantortype, a.grantee, a.granteetype, b.seqschema, b.seqname, 
a.alterauth, a.usageauth 
from sysibm.syssequenceauth as a, sysibm.syssequences as b 
where a.seqid = b.seqid;

CREATE VIEW "SYSCAT"."SEQUENCES" ("SEQSCHEMA", "SEQNAME", "DEFINER", "DEFINERTYPE", "OWNER", "OWNERTYPE", "SEQID", "SEQTYPE", "BASE_SEQSCHEMA", "BASE_SEQNAME", "INCREMENT", "START", "MAXVALUE", "MINVALUE", "NEXTCACHEFIRSTVALUE", "CYCLE", "CACHE", "ORDER", "DATATYPEID", "SOURCETYPEID", "CREATE_TIME", "ALTER_TIME", "PRECISION", "ORIGIN", "REMARKS") AS
select 
a.seqschema, a.seqname, a.definer, a.definertype, a.owner, a.ownertype, 
a.seqid, a.seqtype, a.base_seqschema, a.base_seqname, a.increment, a.start, 
a.maxvalue, a.minvalue, 
case when a.lastassignedval + a.increment > a.maxvalue 
and a.increment > 0 
then case when a.cycle = 'Y' then a.minvalue else null end 
when a.lastassignedval + a.increment < a.minvalue 
and a.increment < 0 
then case when a.cycle = 'Y' then a.maxvalue else null end 
else coalesce(a.lastassignedval + a.increment, a.start) end, 
a.cycle, a.cache, 
a.order, a.datatypeid, a.sourcetypeid, a.create_time, 
a.alter_time, a.precision, a.origin, b.remarks 
from sysibm.syssequences as a left outer join 
sysibm.syscomments as b 
on a.seqid = b.objectid and b.objecttype = 'Q';

CREATE VIEW "SYSCAT"."SERVEROPTIONS" ("WRAPNAME", "SERVERNAME", "SERVERTYPE", "SERVERVERSION", "CREATE_TIME", "OPTION", "SETTING", "SERVEROPTIONKEY", "REMARKS") AS
select 
wrapname, servername, servertype, serverversion, 
create_time, option, setting, serveroptionkey, remarks 
from sysibm.sysserveroptions;

CREATE VIEW "SYSCAT"."SERVERS" ("WRAPNAME", "SERVERNAME", "SERVERTYPE", "SERVERVERSION", "REMARKS") AS
select 
wrapname, servername, servertype, serverversion, remarks 
from sysibm.sysservers;

CREATE VIEW "SYSCAT"."SERVICECLASSES" ("SERVICECLASSNAME", "PARENTSERVICECLASSNAME", "SERVICECLASSID", "PARENTID", "CREATE_TIME", "ALTER_TIME", "ENABLED", "AGENTPRIORITY", "PREFETCHPRIORITY", "BUFFERPOOLPRIORITY", "INBOUNDCORRELATOR", "OUTBOUNDCORRELATOR", "COLLECTAGGACTDATA", "COLLECTAGGREQDATA", "COLLECTACTDATA", "COLLECTACTPARTITION", "COLLECTREQMETRICS", "REMARKS") AS
select 
a.serviceclassname, b.serviceclassname, a.serviceclassid, a.parentid, 
a.create_time, a.alter_time, a.enabled, a.agentpriority, 
a.prefetchpriority, a.bufferpoolpriority, 
a.inboundcorrelator, a.outboundcorrelator, a.collectaggactdata, 
a.collectaggreqdata, a.collectactdata, a.collectactpartition, 
a.collectreqmetrics, c.remarks 
from ( sysibm.sysserviceclasses as a 
left outer join sysibm.sysserviceclasses as b 
on a.parentid = b.serviceclassid 
left outer join sysibm.syscomments as c 
on c.objecttype = 'b' and c.objectid = a.serviceclassid );

CREATE VIEW "SYSCAT"."STATEMENTS" ("PKGSCHEMA", "PKGNAME", "STMTNO", "SECTNO", "SEQNO", "TEXT", "UNIQUE_ID", "VERSION") AS
select 
s.plcreator, s.plname, 
s.stmtno, s.sectno, 1, s.text, s.unique_id, 
(select p.pkgversion from sysibm.sysplan p 
where s.plcreator = p.creator 
and s.plname = p.name 
and s.unique_id = p.unique_id) 
from sysibm.sysstmt s;

CREATE VIEW "SYSCAT"."SURROGATEAUTHIDS" ("GRANTOR", "TRUSTEDID", "TRUSTEDIDTYPE", "SURROGATEAUTHID", "SURROGATEAUTHIDTYPE", "AUTHENTICATE", "CONTEXTROLE", "GRANT_TIME") AS
select grantor, trustedid,  trustedidtype, surrogateauthid, 
surrogateauthidtype, authenticate, contextrole, grant_time 
from sysibm.syssurrogateauthids;

CREATE VIEW "SYSCAT"."TABAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "TABSCHEMA", "TABNAME", "CONTROLAUTH", "ALTERAUTH", "DELETEAUTH", "INDEXAUTH", "INSERTAUTH", "REFAUTH", "SELECTAUTH", "UPDATEAUTH") AS
select 
grantor, grantortype, grantee, granteetype, tcreator, ttname, 
controlauth, alterauth, deleteauth, indexauth, insertauth, 
refauth, selectauth, updateauth 
from sysibm.systabauth;

CREATE VIEW "SYSCAT"."TABCONST" ("CONSTNAME", "TABSCHEMA", "TABNAME", "OWNER", "OWNERTYPE", "TYPE", "ENFORCED", "CHECKEXISTINGDATA", "ENABLEQUERYOPT", "DEFINER", "REMARKS") AS
select 
name, tbcreator, tbname, definer, definertype, constraintyp, 
enforced, checkexistingdata, enablequeryopt, definer, remarks 
from sysibm.systabconst;

CREATE VIEW "SYSCAT"."TABDEP" ("TABSCHEMA", "TABNAME", "DTYPE", "OWNER", "OWNERTYPE", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH", "VARAUTH", "DEFINER") AS
select 
dcreator, dname, dtype, vcauthid, vcauthidtype, btype, bcreator, 
m.modulename, bname, bmoduleid, 
case when btype <> 'v' then tabauth else SMALLINT(0) end, 
case when btype = 'v' then tabauth else SMALLINT(0) end, vcauthid 
from sysibm.sysviewdep left outer join sysibm.sysmodules m on bmoduleid=m.moduleid;

CREATE VIEW "SYSCAT"."TABDETACHEDDEP" ("TABSCHEMA", "TABNAME", "DEPTABSCHEMA", "DEPTABNAME") AS
select 
bschema, bname, dschema, dname 
from sysibm.sysdependencies 
where btype = 'L';

CREATE VIEW "SYSCAT"."TABLES" ("TABSCHEMA", "TABNAME", "OWNER", "OWNERTYPE", "TYPE", "STATUS", "BASE_TABSCHEMA", "BASE_TABNAME", "ROWTYPESCHEMA", "ROWTYPENAME", "CREATE_TIME", "ALTER_TIME", "INVALIDATE_TIME", "STATS_TIME", "COLCOUNT", "TABLEID", "TBSPACEID", "CARD", "NPAGES", "FPAGES", "OVERFLOW", "TBSPACE", "INDEX_TBSPACE", "LONG_TBSPACE", "PARENTS", "CHILDREN", "SELFREFS", "KEYCOLUMNS", "KEYINDEXID", "KEYUNIQUE", "CHECKCOUNT", "DATACAPTURE", "CONST_CHECKED", "PMAP_ID", "PARTITION_MODE", "LOG_ATTRIBUTE", "PCTFREE", "APPEND_MODE", "REFRESH", "REFRESH_TIME", "LOCKSIZE", "VOLATILE", "ROW_FORMAT", "PROPERTY", "STATISTICS_PROFILE", "COMPRESSION", "ACCESS_MODE", "CLUSTERED", "ACTIVE_BLOCKS", "DROPRULE", "MAXFREESPACESEARCH", "AVGCOMPRESSEDROWSIZE", "AVGROWCOMPRESSIONRATIO", "AVGROWSIZE", "PCTROWSCOMPRESSED", "LOGINDEXBUILD", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "ENCODING_SCHEME", "PCTPAGESSAVED", "LAST_REGEN_TIME", "SECPOLICYID", "PROTECTIONGRANULARITY", "AUDITPOLICYID", "AUDITPOLICYNAME", "DEFINER", "ONCOMMIT", "LOGGED", "ONROLLBACK", "LASTUSED", "REMARKS") AS
select 
creator, name, definer, definertype, type, status, 
base_schema, base_name, rowtypeschema, rowtypename, 
ctime, alter_time, invalidate_time, stats_time, colcount, 
fid, tid, card, npages, fpages, overflow, tbspace, 
index_tbspace, long_tbspace, parents, children, selfrefs, 
keycolumns, keyobid, keyunique, checkcount, 
data_capture, const_checked, pmap_id, partition_mode, 
cast('0' as char(1)), pctfree, append_mode, refresh, 
refresh_time, locksize, volatile, cast('N' as char(1)), 
property, statistics_profile, compression, 
access_mode, clustered, active_blocks, droprule, maxfreespacesearch, 
avgcompressedrowsize, avgrowcompressionratio, avgrowsize, 
pctrowscompressed, 
cast (case when logindexbuild='N' then 'OFF' 
when logindexbuild='Y' then 'ON' else NULL end as varchar(3)), 
codepage, 
coalesce((select c1.collationschema from sysibm.syscollations c1 
where t.collationid = c1.collationid), 'SYSIBM'), 
coalesce((select c1.collationname from sysibm.syscollations c1 
where t.collationid = c1.collationid), 
syscat.collationname(t.collationid)), 
coalesce((select c2.collationschema from sysibm.syscollations c2 
where t.collationid_orderby = c2.collationid), 'SYSIBM'), 
coalesce((select c2.collationname from sysibm.syscollations c2 
where t.collationid_orderby = c2.collationid), 
syscat.collationname(t.collationid_orderby)), 
encoding_scheme, pctpagessaved, last_regen_time, 
secpolicyid, protectiongranularity, auditpolicyid, 
case when t.auditpolicyid is null then null 
else (select auditpolicyname from sysibm.sysauditpolicies aud 
where t.auditpolicyid = aud.auditpolicyid) 
end, 
definer, oncommit, logged, onrollback, lastused, remarks 
from sysibm.systables t;

CREATE VIEW "SYSCAT"."TABLESPACES" ("TBSPACE", "OWNER", "OWNERTYPE", "CREATE_TIME", "TBSPACEID", "TBSPACETYPE", "DATATYPE", "EXTENTSIZE", "PREFETCHSIZE", "OVERHEAD", "TRANSFERRATE", "WRITEOVERHEAD", "WRITETRANSFERRATE", "PAGESIZE", "DBPGNAME", "BUFFERPOOLID", "DROP_RECOVERY", "NGNAME", "DEFINER", "DATAPRIORITY", "REMARKS") AS
select 
tbspace, definer, definertype, create_time, tbspaceid, tbspacetype, 
datatype, extentsize, prefetchsize, overhead, transferrate, 
writeoverhead, writetransferrate, pagesize, ngname, bufferpoolid, 
drop_recovery, ngname, definer, datapriority, remarks 
from sysibm.systablespaces;

CREATE VIEW "SYSCAT"."TABOPTIONS" ("TABSCHEMA", "TABNAME", "OPTION", "SETTING") AS
select 
tabschema, tabname, option, setting 
from sysibm.systaboptions;

CREATE VIEW "SYSCAT"."TBSPACEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "TBSPACE", "USEAUTH") AS
select 
grantor, grantortype, grantee, granteetype, tbspace, useauth 
from sysibm.systbspaceauth;

CREATE VIEW "SYSCAT"."THRESHOLDS" ("THRESHOLDNAME", "THRESHOLDID", "ORIGIN", "THRESHOLDCLASS", "THRESHOLDPREDICATE", "THRESHOLDPREDICATEID", "DOMAIN", "DOMAINID", "ENFORCEMENT", "QUEUING", "MAXVALUE", "QUEUESIZE", "COLLECTACTDATA", "COLLECTACTPARTITION", "EXECUTION", "REMAPSCID", "VIOLATIONRECORDLOGGED", "CHECKINTERVAL", "ENABLED", "CREATE_TIME", "ALTER_TIME", "REMARKS") AS
select 
t.thresholdname, t.thresholdid, t.origin, t.thresholdclass, 
t.thresholdpredicate, t.thresholdpredicateid, t.domain, t.domainid, 
t.enforcement, t.queuing, t.maxvalue, t.queuesize, t.collectactdata, 
t.collectactpartition, t.execution, t.remapscid, t.violationrecordlogged, 
t.checkinterval, t.enabled, t.create_time, t.alter_time, c.remarks 
from sysibm.systhresholds t left outer join sysibm.syscomments c 
on t.thresholdid = c.objectid and c.objecttype = 'f';

CREATE VIEW "SYSCAT"."TRANSFORMS" ("TYPEID", "TYPESCHEMA", "TYPENAME", "GROUPNAME", "FUNCID", "FUNCSCHEMA", "FUNCNAME", "SPECIFICNAME", "TRANSFORMTYPE", "FORMAT", "MAXLENGTH", "ORIGIN", "REMARKS") AS
select 
d.typeid, d.schema, d.name, t.groupname, f.routine_id, 
f.routineschema, f.routinename, f.specificname, 'FROM SQL', 
t.fromsql_format, t.fromsql_length, t.origin, t.remarks 
from sysibm.systransforms as t, 
sysibm.sysdatatypes as d, 
sysibm.sysroutines as f 
where t.typeid = d.typeid 
and t.fromsql_funcid = f.routine_id 
and f.routinetype in ('F', 'M') 
and f.routineschema not in ('SYSIBMINTERNAL') 
union all 
select d.typeid, d.schema, d.name, t.groupname, 
f.routine_id, f.routineschema, f.routinename, f.specificname, 
'TO SQL', t.tosql_format, cast(NULL as integer), 
t.origin, t.remarks 
from sysibm.systransforms as t, 
sysibm.sysdatatypes as d, 
sysibm.sysroutines as f 
where t.typeid = d.typeid 
and t.tosql_funcid = f.routine_id 
and f.routinetype in ('F', 'M') 
and f.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSCAT"."TRIGDEP" ("TRIGSCHEMA", "TRIGNAME", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, dname, btype, bschema, m.modulename, bname, bmoduleid, tabauth 
from sysibm.sysdependencies 
left outer join sysibm.sysmodules m on bmoduleid=m.moduleid 
where dtype = 'B';

CREATE VIEW "SYSCAT"."TRIGGERS" ("TRIGSCHEMA", "TRIGNAME", "OWNER", "OWNERTYPE", "TABSCHEMA", "TABNAME", "TRIGTIME", "TRIGEVENT", "GRANULARITY", "VALID", "CREATE_TIME", "QUALIFIER", "FUNC_PATH", "TEXT", "LAST_REGEN_TIME", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "DEFINER", "REMARKS") AS
select 
schema, name, definer, definertype, tbcreator, tbname, 
trigtime, trigevent, granularity, valid, 
create_time, qualifier, func_path, text, 
last_regen_time, 
coalesce(c1.collationschema, 'SYSIBM'), 
coalesce(c1.collationname, syscat.collationname(t.collationid)), 
coalesce(c2.collationschema, 'SYSIBM'), 
coalesce(c2.collationname, syscat.collationname(t.collationid_orderby)), 
definer, remarks 
from sysibm.systriggers t 
left outer join sysibm.syscollations as c1 
on t.collationid = c1.collationid 
left outer join sysibm.syscollations as c2 
on t.collationid_orderby = c2.collationid;

CREATE VIEW "SYSCAT"."TYPEMAPPINGS" ("TYPE_MAPPING", "MAPPINGDIRECTION", "TYPESCHEMA", "TYPENAME", "TYPEID", "SOURCETYPEID", "OWNER", "OWNERTYPE", "LENGTH", "SCALE", "LOWER_LEN", "UPPER_LEN", "LOWER_SCALE", "UPPER_SCALE", "S_OPR_P", "BIT_DATA", "WRAPNAME", "SERVERNAME", "SERVERTYPE", "SERVERVERSION", "REMOTE_TYPESCHEMA", "REMOTE_TYPENAME", "REMOTE_META_TYPE", "REMOTE_LOWER_LEN", "REMOTE_UPPER_LEN", "REMOTE_LOWER_SCALE", "REMOTE_UPPER_SCALE", "REMOTE_S_OPR_P", "REMOTE_BIT_DATA", "USER_DEFINED", "CREATE_TIME", "DEFINER", "REMARKS") AS
select 
type_mapping, mappingdirection, 
typeschema, typename, typeid, sourcetypeid, definer, definertype, 
upper_len, upper_scale, lower_len, upper_len, 
lower_scale, upper_scale, s_opr_p, bit_data, 
wrapname, servername, servertype, serverversion, 
remote_typeschema, remote_typename, remote_meta_type, 
remote_lower_len, remote_upper_len, remote_lower_scale, remote_upper_scale, 
remote_s_opr_p, remote_bit_data, user_defined, create_time, definer, remarks 
from sysibm.systypemappings;

CREATE VIEW "SYSCAT"."USEROPTIONS" ("AUTHID", "AUTHIDTYPE", "SERVERNAME", "OPTION", "SETTING") AS
select 
authid, authidtype, servername, option, 
case 
when option = 'REMOTE_PASSWORD' then '********' 
else setting 
end 
from sysibm.sysuseroptions;

CREATE VIEW "SYSCAT"."VARIABLEAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "VARSCHEMA", "VARNAME", "VARID", "READAUTH", "WRITEAUTH") AS
select 
a.grantor, a.grantortype, a.grantee, a.granteetype, 
b.varschema, b.varname,  a.varid, a.readauth, a.writeauth 
from 
sysibm.sysvariableauth as a, sysibm.sysvariables as b 
where a.varid = b.varid;

CREATE VIEW "SYSCAT"."VARIABLEDEP" ("VARSCHEMA", "VARMODULENAME", "VARNAME", "VARMODULEID", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
dschema, md.modulename, dname, dmoduleid, 
btype, bschema, mb.modulename, bname, bmoduleid, tabauth 
from 
sysibm.sysdependencies 
left outer join sysibm.sysmodules md on dmoduleid=md.moduleid 
left outer join sysibm.sysmodules mb on bmoduleid=mb.moduleid 
where dtype = 'v';

CREATE VIEW "SYSCAT"."VARIABLES" ("VARSCHEMA", "VARMODULENAME", "VARNAME", "VARMODULEID", "VARID", "OWNER", "OWNERTYPE", "CREATE_TIME", "LAST_REGEN_TIME", "VALID", "PUBLISHED", "TYPESCHEMA", "TYPEMODULENAME", "TYPENAME", "TYPEMODULEID", "LENGTH", "SCALE", "CODEPAGE", "COLLATIONSCHEMA", "COLLATIONNAME", "COLLATIONSCHEMA_ORDERBY", "COLLATIONNAME_ORDERBY", "SCOPE", "DEFAULT", "QUALIFIER", "FUNC_PATH", "REMARKS", "READONLY") AS
select 
v.varschema, m.modulename, v.varname, v.varmoduleid, v.varid, 
v.owner, v.ownertype, v.create_time, v.last_regen_time, 
v.valid, v.published, d.schema, m1.modulename, d.name, d.typemoduleid, 
v.length, v.scale, v.codepage, coalesce(c1.collationschema, 'SYSIBM'), 
coalesce(c1.collationname, syscat.collationname(v.collationid)), 
coalesce(c2.collationschema, 'SYSIBM'), 
coalesce(c2.collationname, syscat.collationname(v.collationid_orderby)), 
v.scope, v.default, v.qualifier, v.func_path, c.remarks, v.readonly 
from 
sysibm.sysvariables as v 
left outer join sysibm.sysdatatypes as d on v.typeid = d.typeid 
left outer join sysibm.sysmodules m1 on d.typemoduleid = m1.moduleid 
left outer join sysibm.sysmodules m on v.varmoduleid = m.moduleid 
left outer join sysibm.syscomments as c 
on v.varid = c.objectid and c.objecttype = 'v' 
left outer join sysibm.syscollations as c1 
on v.collationid = c1.collationid 
left outer join sysibm.syscollations as c2 
on v.collationid_orderby = c2.collationid 
where NOT(d.schema = 'SYSPROC' AND d.name = 'DB2SQLSTATE') OR 
(d.schema IS NULL OR d.name IS NULL);

CREATE VIEW "SYSCAT"."VIEWDEP" ("VIEWSCHEMA", "VIEWNAME", "DTYPE", "OWNER", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH", "DEFINER") AS
select 
dcreator, dname, dtype, vcauthid, btype, bcreator, m.modulename, bname, bmoduleid, 
case when btype <> 'v' then tabauth else SMALLINT(0) end, vcauthid 
from sysibm.sysviewdep left outer join sysibm.sysmodules m on bmoduleid=m.moduleid;

CREATE VIEW "SYSCAT"."VIEWS" ("VIEWSCHEMA", "VIEWNAME", "OWNER", "OWNERTYPE", "SEQNO", "VIEWCHECK", "READONLY", "VALID", "QUALIFIER", "FUNC_PATH", "TEXT", "DEFINER") AS
select 
creator, name, definer, definertype, 1, check, readonly, 
valid, qualifier, func_path, text, definer 
from sysibm.sysviews;

CREATE VIEW "SYSCAT"."WORKACTIONS" ("ACTIONNAME", "ACTIONID", "ACTIONSETNAME", "ACTIONSETID", "WORKCLASSNAME", "WORKCLASSID", "CREATE_TIME", "ALTER_TIME", "ENABLED", "ACTIONTYPE", "REFOBJECTID", "REFOBJECTTYPE") AS
select 
a.actionname, a.actionid, b.actionsetname, a.actionsetid, c.workclassname, 
a.workclassid, a.create_time, a.alter_time, a.enabled, a.actiontype, 
a.refobjectid, 
cast(case when a.actiontype = 't' then 'THRESHOLD' 
when a.actiontype in ('m','n') then 'SERVICE CLASS' 
else null end as varchar(30)) 
from sysibm.sysworkactions as a left outer join sysibm.sysworkactionsets as b 
on a.actionsetid = b.actionsetid 
left outer join sysibm.sysworkclasses as c 
on a.workclassid = c.workclassid;

CREATE VIEW "SYSCAT"."WORKACTIONSETS" ("ACTIONSETNAME", "ACTIONSETID", "WORKCLASSSETNAME", "WORKCLASSSETID", "CREATE_TIME", "ALTER_TIME", "ENABLED", "OBJECTTYPE", "OBJECTNAME", "OBJECTID", "REMARKS") AS
select 
a.actionsetname, a.actionsetid, b.workclasssetname, a.workclasssetid, 
a.create_time, a.alter_time, a.enabled, a.objecttype, 
case when a.objecttype = 'b' then c.serviceclassname 
when a.objecttype = 'w' then e.workloadname 
else null end, 
a.objectid, d.remarks 
from sysibm.sysworkactionsets as a left outer join sysibm.sysserviceclasses as c 
on c.serviceclassid = a.objectid 
left outer join sysibm.sysworkloads as e 
on e.workloadid = a.objectid 
left outer join sysibm.sysworkclasssets as b 
on a.workclasssetid = b.workclasssetid 
left outer join sysibm.syscomments as d 
on d.objectid = a.actionsetid and d.objecttype = 'a';

CREATE VIEW "SYSCAT"."WORKCLASSES" ("WORKCLASSNAME", "WORKCLASSSETNAME", "WORKCLASSID", "WORKCLASSSETID", "CREATE_TIME", "ALTER_TIME", "WORKTYPE", "RANGEUNITS", "FROMVALUE", "TOVALUE", "ROUTINESCHEMA", "INITIALSQLDATAPRIORITY", "EVALUATIONORDER") AS
select 
a.workclassname, b.workclasssetname, a.workclassid, a.workclasssetid, 
a.create_time, a.alter_time, a.worktype, a.rangeunits, a.fromvalue, 
a.tovalue, a.routineschema, a.initialsqldatapriority, a.evaluationorder 
from sysibm.sysworkclasses as a left outer join sysibm.sysworkclasssets as b 
on a.workclasssetid = b.workclasssetid;

CREATE VIEW "SYSCAT"."WORKCLASSSETS" ("WORKCLASSSETNAME", "WORKCLASSSETID", "CREATE_TIME", "ALTER_TIME", "REMARKS") AS
select 
a.workclasssetname, a.workclasssetid, a.create_time, a.alter_time, b.remarks 
from sysibm.sysworkclasssets as a left outer join sysibm.syscomments as b 
on b.objectid = a.workclasssetid and b.objecttype = 'e';

CREATE VIEW "SYSCAT"."WORKLOADAUTH" ("WORKLOADID", "WORKLOADNAME", "GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "USAGEAUTH") AS
select 
w.workloadid, w.workloadname, a.grantor, a.grantortype, a.grantee, 
a.granteetype, a.usageauth 
from sysibm.sysworkloads w, sysibm.sysworkloadauth a 
where w.workloadid = a.workloadid;

CREATE VIEW "SYSCAT"."WORKLOADCONNATTR" ("WORKLOADID", "WORKLOADNAME", "CONNATTRTYPE", "CONNATTRVALUE") AS
select 
w.workloadid, w.workloadname, 
cast (case c.connattrid 
when 1 then 'APPLNAME' 
when 2 then 'SYSTEM_USER' 
when 3 then 'SESSION_USER' 
when 4 then 'SESSION_USER GROUP' 
when 5 then 'SESSION_USER ROLE' 
when 6 then 'CURRENT CLIENT_USERID' 
when 7 then 'CURRENT CLIENT_APPLNAME' 
when 8 then 'CURRENT CLIENT_WRKSTNNAME' 
when 9 then 'CURRENT CLIENT_ACCTNG' 
when 10 then 'ADDRESS' 
else 'UNKNOWN' 
end as varchar(30)), 
c.connattrvalue 
from sysibm.sysworkloads w, sysibm.sysworkloadconnattr c 
where w.workloadid = c.workloadid;

CREATE VIEW "SYSCAT"."WORKLOADS" ("WORKLOADID", "WORKLOADNAME", "EVALUATIONORDER", "CREATE_TIME", "ALTER_TIME", "ENABLED", "ALLOWACCESS", "SERVICECLASSNAME", "PARENTSERVICECLASSNAME", "COLLECTAGGACTDATA", "COLLECTACTDATA", "COLLECTACTPARTITION", "COLLECTDEADLOCK", "COLLECTLOCKTIMEOUT", "COLLECTLOCKWAIT", "LOCKWAITVALUE", "COLLECTACTMETRICS", "COLLECTUOWDATA", "EXTERNALNAME", "REMARKS") AS
select 
w.workloadid, w.workloadname, w.evaluationorder, w.create_time, 
w.alter_time, w.enabled, w.allowaccess, s1.serviceclassname, 
s2.serviceclassname, w.collectaggactdata, w.collectactdata, 
w.collectactpartition, w.collectdeadlock, w.collectlocktimeout, 
w.collectlockwait, w.lockwaitvalue, w.collectactmetrics, 
w.collectuowdata, w.externalname, c.remarks 
from sysibm.sysworkloads w left outer join sysibm.syscomments c 
on w.workloadid = c.objectid and c.objecttype = 'w' 
inner join sysibm.sysserviceclasses s1 
on s1.serviceclassid = w.serviceclassid 
left outer join sysibm.sysserviceclasses s2 
on s1.parentid = s2.serviceclassid;

CREATE VIEW "SYSCAT"."WRAPOPTIONS" ("WRAPNAME", "OPTION", "SETTING") AS
select 
wrapname, option, setting 
from sysibm.syswrapoptions;

CREATE VIEW "SYSCAT"."WRAPPERS" ("WRAPNAME", "WRAPTYPE", "WRAPVERSION", "LIBRARY", "REMARKS") AS
select 
wrapname, wraptype, wrapversion, library, remarks 
from sysibm.syswrappers;

CREATE VIEW "SYSCAT"."XDBMAPGRAPHS" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "SCHEMAGRAPHID", "NAMESPACE", "ROOTELEMENT") AS
select 
o.xsrobjectid, o.xsrobjectschema, o.xsrobjectname, m.schemagraphid, 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where m.namespaceid=stringid), 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where m.rootelementid=stringid) 
from sysibm.sysxdbmapgraphs m, 
sysibm.sysxsrobjects o 
where o.xsrobjectid=m.xsrobjectid;

CREATE VIEW "SYSCAT"."XDBMAPSHREDTREES" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "SCHEMAGRAPHID", "SHREDTREEID", "MAPPINGDESCRIPTION") AS
select 
o.xsrobjectid, o.xsrobjectschema, o.xsrobjectname, m.schemagraphid, 
m.shredtreeid, m.mappingdescription 
from sysibm.sysxdbmapshredtrees m, 
sysibm.sysxsrobjects o 
where o.xsrobjectid=m.xsrobjectid;

CREATE VIEW "SYSCAT"."XMLSTRINGS" ("STRINGID", "STRING", "STRING_UTF8") AS
select 
stringid, 
substr(sysibm.xmlbit2char(string), 1, length(sysibm.xmlbit2char(string)) - 1), 
substr(string, 1, length(string) - 1) 
from sysibm.sysxmlstrings;

CREATE VIEW "SYSCAT"."XSROBJECTAUTH" ("GRANTOR", "GRANTORTYPE", "GRANTEE", "GRANTEETYPE", "OBJECTID", "USAGEAUTH") AS
select 
grantor, grantortype, grantee, granteetype, xsrobjectid, usageauth 
from sysibm.sysxsrobjectauth;

CREATE VIEW "SYSCAT"."XSROBJECTCOMPONENTS" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "COMPONENTID", "TARGETNAMESPACE", "SCHEMALOCATION", "COMPONENT", "CREATE_TIME", "STATUS") AS
select 
o.xsrobjectid, o.xsrobjectschema, o.xsrobjectname, c.xsrcomponentid, 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where c.targetnamespaceid=stringid), 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where c.schemalocationid=stringid), 
c.component, c.create_time, c.status 
from sysibm.sysxsrobjects o, 
sysibm.sysxsrobjectcomponents c, 
sysibm.sysxsrobjecthierarchies h 
where o.xsrobjectid=h.xsrobjectid 
and c.xsrcomponentid=h.xsrcomponentid 
and (h.htype='P' or h.htype='D');

CREATE VIEW "SYSCAT"."XSROBJECTDEP" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "BTYPE", "BSCHEMA", "BMODULENAME", "BNAME", "BMODULEID", "TABAUTH") AS
select 
x.xsrobjectid, d.dschema, d.dname, d.btype, 
d.bschema, m.modulename, d.bname, d.bmoduleid, d.tabauth 
from sysibm.sysdependencies d 
left outer join sysibm.sysmodules m on d.bmoduleid=m.moduleid, 
sysibm.sysxsrobjects x 
where d.dtype = 'Z' and 
x.xsrobjectname=d.dname and x.xsrobjectschema=d.dschema;

CREATE VIEW "SYSCAT"."XSROBJECTDETAILS" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "GRAMMAR", "PROPERTIES") AS
select 
o.xsrobjectid, o.xsrobjectschema, o.xsrobjectname, 
o.grammar, o.properties 
from sysibm.sysxsrobjects as o 
where o.objecttype='S';

CREATE VIEW "SYSCAT"."XSROBJECTHIERARCHIES" ("OBJECTID", "COMPONENTID", "HTYPE", "TARGETNAMESPACE", "SCHEMALOCATION") AS
select 
o.xsrobjectid, o.xsrcomponentid, o.htype, 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where o.targetnamespaceid=stringid), 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where o.schemalocationid=stringid) 
from sysibm.sysxsrobjecthierarchies o;

CREATE VIEW "SYSCAT"."XSROBJECTS" ("OBJECTID", "OBJECTSCHEMA", "OBJECTNAME", "TARGETNAMESPACE", "SCHEMALOCATION", "OBJECTINFO", "OBJECTTYPE", "OWNER", "OWNERTYPE", "CREATE_TIME", "ALTER_TIME", "STATUS", "DECOMPOSITION", "REMARKS") AS
select 
o.xsrobjectid, o.xsrobjectschema, o.xsrobjectname, 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where o.targetnamespaceid=stringid), 
(select substr(sysibm.xmlbit2char(string), 1, 
length(sysibm.xmlbit2char(string))-1) from sysibm.sysxmlstrings 
where o.schemalocationid=stringid), 
o.objectinfo, o.objecttype, o.owner, o.ownertype, o.create_time, 
o.alter_time, o.status, o.decomposition, c.remarks 
from sysibm.sysxsrobjects as o left outer join sysibm.syscomments as c 
on o.xsrobjectid=c.objectid and c.objecttype='Z';

CREATE VIEW "SYSIBM"."CHECK_CONSTRAINTS" ("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "CONSTRAINT_NAME", "CHECK_CLAUSE") AS
SELECT 
CAST(CURRENT SERVER AS VARCHAR(128)), TBCREATOR, 
CAST(NAME AS VARCHAR(128)), TEXT 
FROM SYSIBM.SYSCHECKS 
WHERE TYPE='C' 
UNION ALL 
SELECT CAST(CURRENT SERVER AS VARCHAR(128)), TBCREATOR, 
CAST(CONCAT(RTRIM(CONCAT(CHAR(CTIME), CHAR(FID) ) ), 
RTRIM(CHAR(COLNO)) ) AS VARCHAR(128) ), 
CAST(CONCAT(CONCAT('CHECK (', C.NAME), ' IS NOT NULL)') AS CLOB(64K) ) 
FROM SYSIBM.SYSCOLUMNS C, SYSIBM.SYSTABLES T 
WHERE C.TBCREATOR = T.CREATOR AND C.TBNAME = T.NAME AND TYPE IN('U', 'T') 
AND NULLS ='N';

CREATE VIEW "SYSIBM"."COLUMNS" ("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "ORDINAL_POSITION", "COLUMN_DEFAULT", "IS_NULLABLE", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH", "CHARACTER_OCTET_LENGTH", "NUMERIC_PRECISION", "NUMERIC_PRECISION_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "CHARACTER_SET_CATALOG", "CHARACTER_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "DOMAIN_CATALOG", "DOMAIN_SCHEMA", "DOMAIN_NAME", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAXIMUM_CARDINALITY", "DTD_IDENTIFIER", "IS_SELF_REFERENCING") AS
SELECT 
CAST(CURRENT SERVER AS VARCHAR(128)), C.TBCREATOR, C.TBNAME, C.NAME, 
CAST(C.COLNO+1  AS INTEGER), CAST(C.DEFAULT AS VARCHAR(2000)), 
CASE C.NULLS 
WHEN 'Y' THEN 'YES' ELSE 'NO' 
END , 
CASE 
WHEN C.COLTYPE='CHAR'     THEN 'CHARACTER' 
WHEN C.COLTYPE='VARCHAR'  THEN 'CHARACTER VARYING' 
WHEN C.COLTYPE='LONGVAR'  THEN 'LONG VARCHAR' 
WHEN C.COLTYPE='INTEGER'  THEN 'INTEGER' 
WHEN C.COLTYPE='SMALLINT' THEN 'SMALLINT' 
WHEN C.COLTYPE='BIGINT'   THEN 'BIGINT' 
WHEN C.COLTYPE='REAL'     THEN 'REAL' 
WHEN C.COLTYPE='DOUBLE'   THEN 'DOUBLE PRECISION' 
WHEN C.COLTYPE='DECIMAL'  THEN 'DECIMAL' 
WHEN C.COLTYPE='BLOB'     THEN 'BINARY LARGE OBJECT' 
WHEN C.COLTYPE='CLOB'     THEN 'CHARACTER LARGE OBJECT' 
WHEN C.COLTYPE='DBCLOB'  THEN 'DOUBLE-BYTE CHARACTER LARGE OBJECT' 
WHEN C.COLTYPE='GRAPHIC'  THEN 'GRAPHIC' 
WHEN C.COLTYPE='VARGRAPH' THEN 'GRAPHIC VARYING' 
WHEN C.COLTYPE='LONGVARG' THEN 'LONG VARGRAPHIC' 
WHEN C.COLTYPE='DATALINK' THEN 'DATALINK' 
WHEN C.COLTYPE='TIME'     THEN 'TIME' 
WHEN C.COLTYPE='DATE'     THEN 'DATE' 
WHEN C.COLTYPE='TIMESTMP' THEN 'TIMESTAMP' 
WHEN C.COLTYPE='DATALINK' THEN 'DATALINK' 
WHEN C.COLTYPE='REF'      THEN 'REF' 
WHEN C.COLTYPE='DISTINCT' THEN 'USER-DEFINED' 
WHEN C.COLTYPE='STRUCT'   THEN 'USER-DEFINED' 
ELSE C.TYPENAME 
END, 
CASE 
WHEN  C.COLTYPE ='CHAR'    THEN CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='VARCHAR' AND C.LENGTH= -1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE ='VARCHAR' AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='LONGVAR'  AND C.LENGTH= -1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE ='LONGVAR' AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE= 'CLOB' AND C.LENGTH=-1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE='CLOB' AND C.LENGTH <>-1 
THEN CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE ='BLOB'  AND  C.LENGTH =-1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE='BLOB' AND C.LENGTH <> -1 
THEN CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='DBCLOB'  AND C.LENGTH =-1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE='DBCLOB' AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='GRAPHIC'  THEN  CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='VARGRAPH' THEN CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='LONGVARG' THEN CAST(C.LENGTH AS INTEGER) 
WHEN  C.COLTYPE='REF'      THEN CAST(C.LENGTH AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN  C.COLTYPE ='CHAR' THEN  CAST(C.LENGTH AS INTEGER) 
WHEN   C.COLTYPE='VARCHAR'  AND C.LENGTH= -1 THEN C.LONGLENGTH 
WHEN  C.COLTYPE ='VARCHAR' AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH AS INTEGER) 
WHEN C.COLTYPE='LONGVAR'  AND C.LENGTH= -1 
THEN C.LONGLENGTH 
WHEN  C.COLTYPE ='LONGVAR'  AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH AS INTEGER) 
WHEN C.COLTYPE= 'CLOB' AND C.LENGTH=-1 
THEN C.LONGLENGTH 
WHEN C.COLTYPE='CLOB' AND C.LENGTH <>-1 
THEN CAST(C.LENGTH AS INTEGER) 
WHEN C.COLTYPE ='BLOB'  AND  C.LENGTH =-1 
THEN C.LONGLENGTH 
WHEN C.COLTYPE='BLOB' AND C.LENGTH <> -1 
THEN CAST(C.LENGTH AS INTEGER) 
WHEN C.COLTYPE='DBCLOB'  AND C.LENGTH =-1 
THEN C.LONGLENGTH*2 
WHEN C.COLTYPE='DBCLOB' AND C.LENGTH <> -1 
THEN  CAST(C.LENGTH*2  AS INTEGER) 
WHEN  C.COLTYPE='GRAPHIC'       THEN  CAST(C.LENGTH*2 AS INTEGER) 
WHEN  C.COLTYPE='VARGRAPH'  THEN  CAST(C.LENGTH*2 AS INTEGER) 
WHEN  C.COLTYPE='LONGVARG' THEN CAST(C.LENGTH*2 AS INTEGER) 
WHEN  C.COLTYPE='REF' THEN  CAST(C.LENGTH AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE C.COLTYPE 
WHEN 'INTEGER'  THEN 10 
WHEN 'BIGINT'          THEN 19 
WHEN 'SMALLINT'        THEN 5 
WHEN 'REAL'            THEN 24 
WHEN 'DOUBLE'          THEN 53 
WHEN 'DECIMAL' THEN CAST(C.LENGTH AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE   C.COLTYPE 
WHEN 'INTEGER'        THEN 10 
WHEN 'BIGINT'         THEN 10 
WHEN 'SMALLINT'       THEN 10 
WHEN 'REAL'           THEN 2 
WHEN 'DOUBLE'         THEN 2 
WHEN 'DECIMAL'        THEN 10 ELSE CAST(NULL AS INTEGER) 
END  , 
CASE  C.COLTYPE 
WHEN 'DECIMAL'     THEN CAST(C.SCALE AS INTEGER) 
WHEN 'INTEGER'     THEN 0 
WHEN 'SMALLINT'    THEN 0 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE  C.COLTYPE 
WHEN 'DATE'          THEN 0 
WHEN 'TIME'          THEN 0 
WHEN 'TIMESTMP'      THEN  CAST(C.SCALE AS INTEGER) 
ELSE  CAST(NULL AS INTEGER) 
END, 
CAST(NULL AS VARCHAR(128)) , 
CAST(NULL AS INTEGER) , 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST(CONCAT('IBM',CHAR(C.CODEPAGE)) AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN C.COLTYPE IN ('CHAR'   ,'VARCHAR' ,'LONGVAR' ,'CLOB', 
'GRAPHIC','VARGRAPH','LONGVARG','DBCLOB') 
THEN CAST('IBMDEFAULT' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CAST (NULL AS VARCHAR(128)), 
CAST (NULL AS VARCHAR(128)), 
CAST (NULL AS VARCHAR(128)), 
CASE C.COLTYPE 
WHEN 'DISTINCT'  THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
WHEN 'REF'       THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
WHEN 'STRUCT'    THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END , 
CASE  C.COLTYPE 
WHEN 'DISTINCT'  THEN TYPESCHEMA 
WHEN 'REF'       THEN P.TARGET_TYPESCHEMA 
WHEN 'STRUCT'    THEN TYPESCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END , 
CASE C.COLTYPE 
WHEN 'DISTINCT'  THEN CAST(TYPENAME AS VARCHAR(128)) 
WHEN 'REF'       THEN CAST(P.TARGET_TYPENAME AS VARCHAR(128)) 
WHEN 'STRUCT'    THEN CAST(TYPENAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE C.COLTYPE 
WHEN  'REF'      THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE C.COLTYPE 
WHEN 'REF'       THEN P.SCOPE_TABSCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE C.COLTYPE 
WHEN  'REF'      THEN P.SCOPE_TABNAME 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CAST(NULL AS INTEGER), 
CAST ( 
CONCAT('C',CONCAT(HEX(T.CTIME), 
CONCAT(HEX(C.COLNO), SUBSTRING(C.TBNAME,1,103,OCTETS)))) 
AS VARCHAR(128) ), 
CASE 
WHEN C.COLTYPE='REF' AND SUBSTR(P.SPECIAL_PROPS,1,1)='Y' 
THEN 'YES' 
ELSE 'NO' 
END 
FROM  (SYSIBM.SYSTABLES T INNER JOIN 
SYSIBM.SYSCOLUMNS C on 
C.TBCREATOR = T.CREATOR AND C.TBNAME = T.NAME) 
LEFT OUTER JOIN 
SYSIBM.SYSCOLPROPERTIES P 
ON   C.TBCREATOR = P.TABSCHEMA 
AND C.TBNAME = P.TABNAME 
AND C.NAME = P.COLNAME;

CREATE VIEW "SYSIBM"."COLUMNS_S" ("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "ORDINAL_POSITION", "COLUMN_DEFAULT", "IS_NULLABLE", "DATA_TYPE", "CHAR_MAX_LENGTH", "CHAR_OCTET_LENGTH", "NUMERIC_PRECISION", "NUMERIC_PREC_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "CHAR_SET_CATALOG", "CHAR_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "DOMAIN_CATALOG", "DOMAIN_SCHEMA", "DOMAIN_NAME", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAX_CARDINALITY", "DTD_IDENTIFIER", "IS_SELF_REF") AS
SELECT 
TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, 
ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, 
CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, 
NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, 
INTERVAL_TYPE, INTERVAL_PRECISION, CHARACTER_SET_CATALOG, 
CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, 
COLLATION_SCHEMA, COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, 
DOMAIN_NAME, UDT_CATALOG, UDT_SCHEMA, UDT_NAME, SCOPE_CATALOG, 
SCOPE_SCHEMA, SCOPE_NAME, MAXIMUM_CARDINALITY, DTD_IDENTIFIER, 
IS_SELF_REFERENCING 
FROM SYSIBM.COLUMNS;

CREATE VIEW "SYSIBM"."DUAL" ("DUMMY") AS
values (char('X'));

CREATE VIEW "SYSIBM"."PARAMETERS" ("SPECIFIC_CATALOG", "SPECIFIC_SCHEMA", "SPECIFIC_NAME", "ORDINAL_POSITION", "PARAMETER_MODE", "IS_RESULT", "AS_LOCATOR", "PARAMETER_NAME", "FROM_SQL_SPECIFIC_CATALOG", "FROM_SQL_SPECIFIC_SCHEMA", "FROM_SQL_SPECIFIC_NAME", "TO_SQL_SPECIFIC_CATALOG", "TO_SQL_SPECIFIC_SCHEMA", "TO_SQL_SPECIFIC_NAME", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH", "CHARACTER_OCTET_LENGTH", "CHARACTER_SET_CATALOG", "CHARACTER_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PRECISION_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAXIMUM_CARDINALITY", "DTD_IDENTIFIER") AS
WITH 
FROM_SQL(FROM_CATALOG, FROM_SCHEMA, FROM_NAME, FROM_GRPNAME, 
FROM_ROUTINE_ID) AS 
( SELECT CURRENT SERVER, R.ROUTINESCHEMA, R.SPECIFICNAME, 
P.TRANSFORM_GRPNAME, R.ROUTINE_ID 
FROM SYSIBM.SYSROUTINEPARMS P, SYSIBM.SYSROUTINES R, 
SYSIBM.SYSTRANSFORMS T 
WHERE  P.TRANSFORM_GRPNAME = T.GROUPNAME 
AND  T.FROMSQL_FUNCID = R.ROUTINE_ID 
AND R.ROUTINESCHEMA <> 'SYSFUN' 
) 
SELECT CAST(CURRENT SERVER AS VARCHAR(128)), ROUTINESCHEMA, SPECIFICNAME, 
CASE ROWTYPE 
WHEN 'P' THEN CAST(ORDINAL AS INTEGER) 
WHEN 'B'      THEN CAST(ORDINAL AS INTEGER) 
WHEN 'O'   THEN  CAST(ORDINAL AS INTEGER) 
END, 
CASE ROWTYPE 
WHEN 'P'        THEN 'IN' 
WHEN 'O'        THEN 'OUT' 
WHEN 'B'        THEN 'INOUT' 
END, 
'NO', 
CASE P.LOCATOR 
WHEN 'Y'       THEN 'YES' 
WHEN 'N'       THEN 'NO' 
END, 
PARMNAME, 
CASE 
WHEN P.ROWTYPE='P'  AND (P.ROUTINETYPE ='F' OR P.ROUTINETYPE='M') 
THEN CAST(FROM_CATALOG AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.ROWTYPE='P'  AND (P.ROUTINETYPE ='F' OR P.ROUTINETYPE='M') 
THEN  FROM_SCHEMA ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.ROWTYPE='P'  AND (P.ROUTINETYPE ='F' OR P.ROUTINETYPE='M') 
THEN CAST(FROM_NAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CAST(NULL AS VARCHAR(128)), 
CAST(NULL AS VARCHAR(128)), 
CAST(NULL AS VARCHAR(128)), 
CASE 
WHEN P.TYPENAME='CHARACTER'       THEN 'CHARACTER' 
WHEN P.TYPENAME='VARCHAR'         THEN 'CHARACTER VARYING' 
WHEN P.TYPENAME='LONG VARCHAR'    THEN 'LONG VARCHAR' 
WHEN P.TYPENAME='INTEGER'         THEN 'INTEGER' 
WHEN P.TYPENAME='SMALLINT'        THEN 'SMALLINT' 
WHEN P.TYPENAME='BIGINT'          THEN 'BIGINT' 
WHEN P.TYPENAME='REAL'            THEN 'REAL' 
WHEN P.TYPENAME='DOUBLE'          THEN 'DOUBLE PRECISION' 
WHEN P.TYPENAME='DECIMAL'         THEN 'DECIMAL' 
WHEN P.TYPENAME='BLOB'            THEN 'BINARY LARGE OBJECT' 
WHEN P.TYPENAME='CLOB'            THEN 'CHARACTER LARGE OBJECT' 
WHEN P.TYPENAME='DBCLOB'  THEN 'DOUBLE-BYTE CHARACTER LARGE OBJECT' 
WHEN P.TYPENAME='GRAPHIC'         THEN 'GRAPHIC' 
WHEN P.TYPENAME='VARGRAPHIC'      THEN 'GRAPHIC VARYING' 
WHEN P.TYPENAME='LONG VARGRAPHIC' THEN 'LONG VARGRAPHIC' 
WHEN P.TYPENAME='DATALINK'        THEN 'DATALINK' 
WHEN P.TYPENAME='TIME'            THEN 'TIME' 
WHEN P.TYPENAME='DATE'            THEN 'DATE' 
WHEN P.TYPENAME='TIMESTAMP'       THEN 'TIMESTAMP' 
WHEN P.TYPENAME='REFERENCE'       THEN 'REF' 
WHEN P.TYPESCHEMA<>'SYSIBM'       THEN 'USER-DEFINED' 
ELSE P.TYPENAME 
END, 
CASE 
WHEN P.TYPENAME IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 'CLOB', 
'GRAPHIC', 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') THEN P.LENGTH 
WHEN P.TYPENAME='BLOB'            THEN P.LENGTH 
WHEN P.TYPENAME='REFERENCE'       THEN P.LENGTH 
ELSE  CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR' , 'LONG VARCHAR' , 'CLOB') THEN P.LENGTH 
WHEN P.TYPENAME IN 
('GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN P.LENGTH * 2 
WHEN P.TYPENAME='BLOB'            THEN P.LENGTH 
WHEN P.TYPENAME='REFERENCE'       THEN P.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CONCAT('IBM', CHAR(P.CODEPAGE)) AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST('IBMDEFAULT' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE P.TYPENAME 
WHEN 'INTEGER'      THEN 10 
WHEN 'BIGINT'       THEN 19 
WHEN 'SMALLINT'     THEN 5 
WHEN 'REAL'         THEN 24 
WHEN 'DOUBLE'       THEN 53 
WHEN 'DECIMAL'      THEN P.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE  P.TYPENAME 
WHEN 'INTEGER'      THEN 10 
WHEN 'BIGINT'       THEN 10 
WHEN 'SMALLINT'     THEN 10 
WHEN 'REAL'         THEN 2 
WHEN 'DOUBLE'       THEN 2 
WHEN 'DECIMAL'      THEN 10 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE P.TYPENAME 
WHEN 'DECIMAL'      THEN CAST(P.SCALE AS INTEGER) 
WHEN 'INTEGER'      THEN 0 
WHEN 'SMALLINT'     THEN 0 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE P.TYPENAME 
WHEN 'DATE'         THEN 0 
WHEN 'TIME'         THEN 0 
WHEN 'TIMESTAMP'    THEN CAST(P.SCALE AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END, 
CAST(NULL AS VARCHAR(128)) , 
CAST(NULL AS INTEGER) , 
CASE 
WHEN P.TYPENAME = 'REFERENCE' 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
WHEN P.TYPESCHEMA <> 'SYSIBM' 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN P.TYPENAME = 'REFERENCE' THEN P.TARGET_TYPESCHEMA 
WHEN P.TYPESCHEMA <> 'SYSIBM' THEN TYPESCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END , 
CASE 
WHEN P.TYPENAME = 'REFERENCE' 
THEN CAST(P.TARGET_TYPENAME AS VARCHAR(128)) 
WHEN P.TYPESCHEMA <> 'SYSIBM' 
THEN CAST(P.TYPENAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN  P.TYPENAME ='REFERENCE' AND P.SCOPE_TABSCHEMA IS NOT NULL 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN  P.TYPENAME='REFERENCE' THEN P.SCOPE_TABSCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN  P.TYPENAME ='REFERENCE' THEN P.SCOPE_TABNAME 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CAST(NULL AS INTEGER), 
CAST(CONCAT('P',CONCAT(HEX(FROM_ROUTINE_ID),CONCAT(P.ROWTYPE, 
HEX(P.ORDINAL)))) AS VARCHAR(128)) 
FROM  SYSIBM.SYSROUTINEPARMS  P 
LEFT OUTER JOIN FROM_SQL ON P.TRANSFORM_GRPNAME = FROM_SQL.FROM_GRPNAME 
WHERE P.ROWTYPE IN  ('P', 'O', 'B') 
AND P.ORDINAL > 0;

CREATE VIEW "SYSIBM"."PARAMETERS_S" ("SPECIFIC_CATALOG", "SPECIFIC_SCHEMA", "SPECIFIC_NAME", "ORDINAL_POSITION", "PARAMETER_MODE", "IS_RESULT", "AS_LOCATOR", "PARAMETER_NAME", "FROM_SQL_SPEC_CAT", "FROM_SQL_SPEC_SCH", "FROM_SQL_SPEC_NAME", "TO_SQL_SPEC_CAT", "TO_SQL_SPEC_SCHEMA", "TO_SQL_SPEC_NAME", "DATA_TYPE", "CHAR_MAX_LENGTH", "CHAR_OCTET_LENGTH", "CHAR_SET_CATALOG", "CHAR_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PREC_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAX_CARDINALITY", "DTD_IDENTIFIER") AS
SELECT 
SPECIFIC_CATALOG, SPECIFIC_SCHEMA, SPECIFIC_NAME, ORDINAL_POSITION, 
PARAMETER_MODE, IS_RESULT, AS_LOCATOR, PARAMETER_NAME, 
FROM_SQL_SPECIFIC_CATALOG, FROM_SQL_SPECIFIC_SCHEMA, 
FROM_SQL_SPECIFIC_NAME, TO_SQL_SPECIFIC_CATALOG, 
TO_SQL_SPECIFIC_SCHEMA, TO_SQL_SPECIFIC_NAME, DATA_TYPE, 
CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, 
CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, 
COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, NUMERIC_PRECISION, 
NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, 
INTERVAL_TYPE, INTERVAL_PRECISION, UDT_CATALOG, UDT_SCHEMA, UDT_NAME, 
SCOPE_CATALOG, SCOPE_SCHEMA, SCOPE_NAME, MAXIMUM_CARDINALITY, 
DTD_IDENTIFIER 
FROM SYSIBM.PARAMETERS;

CREATE VIEW "SYSIBM"."REFERENTIAL_CONSTRAINTS" ("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "CONSTRAINT_NAME", "UNIQUE_CONSTRAINT_CATALOG", "UNIQUE_CONSTRAINT_SCHEMA", "UNIQUE_CONSTRAINT_NAME", "MATCH_OPTION", "UPDATE_RULE", "DELETE_RULE") AS
SELECT CAST(CURRENT SERVER  AS VARCHAR(128)), 
CREATOR , 
CAST(RELNAME            AS VARCHAR(128)), 
CAST(CURRENT SERVER     AS VARCHAR(128)), 
REFTBCREATOR  , 
CAST(REFKEYNAME     AS VARCHAR(128)), 
'NONE' , 
CASE UPDATERULE 
WHEN 'N'      THEN  'RESTRICT' 
WHEN 'A'      THEN 'NO ACTION' 
END , 
CASE DELETERULE 
WHEN 'C'      THEN  'CASCADE' 
WHEN 'N'      THEN 'SET NULL' 
WHEN 'R'      THEN 'RESTRICT' 
WHEN 'A'      THEN 'NO ACTION' 
END 
FROM SYSIBM.SYSRELS;

CREATE VIEW "SYSIBM"."REF_CONSTRAINTS" ("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "CONSTRAINT_NAME", "UNIQUE_CONSTR_CAT", "UNIQUE_CONSTR_SCH", "UNIQUE_CONSTR_NAME", "MATCH_OPTION", "UPDATE_RULE", "DELETE_RULE") AS
SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, 
UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, 
UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE 
FROM SYSIBM.REFERENTIAL_CONSTRAINTS;

CREATE VIEW "SYSIBM"."ROUTINES" ("SPECIFIC_CATALOG", "SPECIFIC_SCHEMA", "SPECIFIC_NAME", "ROUTINE_CATALOG", "ROUTINE_SCHEMA", "ROUTINE_NAME", "ROUTINE_TYPE", "MODULE_CATALOG", "MODULE_SCHEMA", "MODULE_NAME", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH", "CHARACTER_OCTET_LENGTH", "CHARACTER_SET_CATALOG", "CHARACTER_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PRECISION_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "TYPE_UDT_CATALOG", "TYPE_UDT_SCHEMA", "TYPE_UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAXIMUM_CARDINALITY", "DTD_IDENTIFIER", "ROUTINE_BODY", "ROUTINE_DEFINITION", "EXTERNAL_NAME", "EXTERNAL_LANGUAGE", "PARAMETER_STYLE", "IS_DETERMINISTIC", "SQL_DATA_ACCESS", "IS_NULL_CALL", "SQL_PATH", "SCHEMA_LEVEL_ROUTINE", "MAX_DYNAMIC_RESULT_SETS", "IS_USER_DEFINED_CAST", "IS_IMPLICITLY_INVOCABLE", "SECURITY_TYPE", "TO_SQL_SPECIFIC_CATALOG", "TO_SQL_SPECIFIC_SCHEMA", "TO_SQL_SPECIFIC_NAME", "AS_LOCATOR", "CREATED", "LAST_ALTERED") AS
WITH TO_SQL(TO_CATALOG, TO_SCHEMA, TO_NAME, TO_GRPNAME) AS 
( SELECT CURRENT SERVER, R.ROUTINESCHEMA, R.SPECIFICNAME, 
P.TRANSFORM_GRPNAME 
FROM SYSIBM.SYSROUTINEPARMS P, 
SYSIBM.SYSROUTINES R, 
SYSIBM.SYSTRANSFORMS T 
WHERE  P. TRANSFORM_GRPNAME = T.GROUPNAME 
AND       T.TOSQL_FUNCID = R.ROUTINE_ID 
) 
SELECT CAST(CURRENT SERVER AS VARCHAR(128)), 
R.ROUTINESCHEMA, 
CAST(R.SPECIFICNAME     AS VARCHAR(128)), 
CAST(CURRENT SERVER     AS VARCHAR(128)), 
R.ROUTINESCHEMA, 
CAST(R.ROUTINENAME AS VARCHAR(128)), 
CASE 
WHEN R.ROUTINETYPE='P'  THEN 'PROCEDURE' 
WHEN R.ROUTINETYPE='M' AND METHODPROPERTY ='S' 
THEN 'STATIC METHOD' 
WHEN R.ROUTINETYPE='M' AND METHODPROPERTY='I' 
THEN 'INSTANCE METHOD' 
WHEN R.ROUTINETYPE='M' AND METHODPROPERTY='C' 
THEN 'CONSTRUCTOR METHOD' 
WHEN R.ROUTINETYPE='F'  THEN 'FUNCTION' 
END, 
CAST(NULL AS VARCHAR(128)), 
CAST(NULL AS VARCHAR(128)), 
CAST(NULL AS VARCHAR(128)), 
CASE R.ROUTINETYPE 
WHEN 'M'   THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE R.ROUTINETYPE 
WHEN 'M'  THEN SUBJECT_TYPESCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE R.ROUTINETYPE 
WHEN 'M'    THEN CAST(SUBJECT_TYPENAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='CHARACTER' THEN 'CHARACTER' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='VARCHAR'   THEN 'CHARACTER VARYING' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='LONG VARCHAR' THEN 'LONG VARCHAR' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='INTEGER'   THEN 'INTEGER' 
WHEN  (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='SMALLINT'  THEN 'SMALLINT' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='BIGINT'    THEN 'BIGINT' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REAL'  THEN 'REAL' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DOUBLE'    THEN 'DOUBLE PRECISION' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DECIMAL'   THEN 'DECIMAL' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME = 'BLOB'     THEN 'BINARY LARGE OBJECT' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='CLOB'      THEN 'CHARACTER LARGE OBJECT' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DBCLOB'    THEN 'DOUBLE-BYTE CHARACTER LARGE OBJECT' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='GRAPHIC'   THEN 'GRAPHIC' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='VARGRAPHIC' THEN 'GRAPHIC VARYING' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='LONG VARGRAPHIC'   THEN 'LONG VARGRAPHIC' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DATALINK'      THEN 'DATALINK' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='TIME'      THEN 'TIME' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DATE'      THEN 'DATE' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='TIMESTAMP'     THEN 'TIMESTAMP' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'     THEN 'REF' 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPESCHEMA <> 'SYSIBM'    THEN 'USER-DEFINED' 
WHEN (R.ROUTINETYPE ='P')            THEN CAST(NULL AS VARCHAR(128)) 
ELSE P.TYPENAME 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN P.LENGTH 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='BLOB'          THEN P.LENGTH 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'     THEN P.LENGTH 
ELSE CAST (NULL AS INTEGER) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB') 
THEN P.LENGTH 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN P.LENGTH*2 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME = 'BLOB'         THEN P.LENGTH 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME='REFERENCE'      THEN P.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST( 'SYSIBM' AS VARCHAR(128)) 
ELSE CAST( NULL  AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CONCAT('IBM',CHAR(P.CODEPAGE)) AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTRE', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST( 'SYSIBM' AS VARCHAR(128)) 
ELSE CAST( NULL  AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME IN 
('CHARACTER', 'VARCHAR'   , 'LONG VARCHAR'   , 'CLOB'  , 
'GRAPHIC'  , 'VARGRAPHIC', 'LONG VARGRAPHIC', 'DBCLOB') 
THEN CAST('IBMDEFAULT' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='INTEGER'   THEN 10 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='BIGINT'    THEN 19 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='SMALLINT'  THEN 5 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REAL'      THEN 24 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DOUBLE'    THEN 53 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DECIMAL'   THEN P.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='INTEGER'   THEN 10 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='BIGINT'    THEN 10 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='SMALLINT'  THEN 10 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REAL'      THEN  2 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DOUBLE'    THEN 2 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DECIMAL'   THEN  10 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DECIMAL'   THEN  CAST(P.SCALE AS INTEGER) 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='INTEGER'   THEN  0 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='SMALLINT'  THEN  0 
ELSE CAST(NULL AS INTEGER) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='DATE'      THEN  0 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='TIME'      THEN 0 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='TIMESTAMP' THEN CAST(P.SCALE AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END, 
CAST(NULL AS VARCHAR(128)) , 
CAST(NULL AS INTEGER) , 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'     THEN 
CAST(CURRENT SERVER AS VARCHAR(128)) 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPESCHEMA <> 'SYSIBM'    THEN 
CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'    THEN TARGET_TYPESCHEMA 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPESCHEMA <> 'SYSIBM'   THEN TYPESCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'    THEN 
CAST(TARGET_TYPENAME AS VARCHAR(128)) 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPESCHEMA <>'SYSIBM'      THEN 
CAST(TYPENAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'  THEN 
CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'    THEN P.SCOPE_TABSCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN (R.ROUTINETYPE ='M' OR R.ROUTINETYPE='F' ) 
AND P.TYPENAME ='REFERENCE'  THEN P.SCOPE_TABNAME 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CAST(NULL AS INTEGER), 
CAST(CONCAT('R',HEX(R.ROUTINE_ID)) AS VARCHAR(128)), 
CASE LANGUAGE 
WHEN 'SQL'   THEN 'SQL' 
ELSE 'EXTERNAL' 
END, 
CASE LANGUAGE 
WHEN 'SQL'      THEN TEXT 
ELSE CAST(NULL AS CLOB(1M)) 
END, 
CAST(CASE 
WHEN LANGUAGE  <>  'SQL'  THEN  IMPLEMENTATION 
ELSE   NULL 
END AS VARCHAR(279) ), 
CASE 
WHEN LANGUAGE <>' SQL' 
THEN CAST(LANGUAGE AS VARCHAR(22)) 
ELSE CAST(NULL AS VARCHAR(22)) 
END, 
CASE PARAMETER_STYLE 
WHEN 'DB2GENRL'     THEN CAST('DB2GENERAL' AS VARCHAR(22)) 
WHEN 'DB2DARI'      THEN CAST('DB2DARI'    AS VARCHAR(22)) 
WHEN 'DB2SQL'       THEN CAST('DB2SQL'     AS VARCHAR(22)) 
WHEN 'JAVA'         THEN CAST('JAVA'       AS VARCHAR(22)) 
WHEN 'GENERAL'      THEN CAST('GENERAL'    AS VARCHAR(22)) 
WHEN 'GNRLNULL'     THEN 
CAST('GENERAL WITH NULLS' AS VARCHAR(22)) 
ELSE CAST(NULL AS VARCHAR(22)) 
END, 
CASE 
WHEN DETERMINISTIC='Y'      THEN 'YES' 
WHEN DETERMINISTIC='N'      THEN 'NO' 
ELSE 'YES' 
END, 
CASE SQL_DATA_ACCESS 
WHEN 'C'        THEN 'CONTAINS SQL' 
WHEN 'M'        THEN 'MODIFIES SQL DATA' 
WHEN 'R'        THEN 'READS SQL DATA' 
WHEN 'N'        THEN 'NO SQL' 
ELSE 'NO SQL' 
END, 
CASE 
WHEN (R.ROUTINETYPE ='F' OR R.ROUTINETYPE='M') 
AND R.NULL_CALL ='N'     THEN 'YES' 
WHEN (R.ROUTINETYPE='F' AND R.ROUTINETYPE='M') 
AND R.NULL_CALL='Y'   THEN 'NO' 
WHEN R.ROUTINETYPE='P' THEN NULL 
ELSE 'NO' 
END, 
CASE LANGUAGE 
WHEN 'SQL'     THEN CAST(FUNC_PATH AS VARCHAR(558)) 
ELSE CAST(NULL AS VARCHAR(558)) 
END, 
'YES', 
CASE R.ROUTINETYPE 
WHEN 'P'        THEN CAST(RESULT_SETS AS INTEGER) 
ELSE 0 
END, 
CASE CAST_FUNCTION 
WHEN 'Y'        THEN 'YES' 
ELSE 'NO' 
END, 
CASE CAST_FUNCTION 
WHEN 'Y'       THEN 'YES' 
ELSE CAST(NULL AS VARCHAR(3)) 
END, 
CASE 
WHEN  LANGUAGE <> 'SQL'     THEN 'IMPLEMENTATION  DEFINED' 
ELSE CAST(NULL AS VARCHAR(22)) 
END, 
CAST(TO_CATALOG AS VARCHAR(128)), 
TO_SCHEMA, 
CAST(TO_NAME AS VARCHAR(128)), 
CASE P.LOCATOR 
WHEN 'Y'    THEN 'YES' 
WHEN 'N'    THEN 'NO' 
END, 
CREATEDTS, 
ALTEREDTS 
FROM  (SYSIBM.SYSROUTINES R 
LEFT OUTER JOIN 
SYSIBM.SYSROUTINEPARMS P 
ON   R.SPECIFICNAME = P.SPECIFICNAME 
AND R.ROUTINESCHEMA = P.ROUTINESCHEMA 
AND P.ROWTYPE ='C' 
) 
LEFT OUTER JOIN 
TO_SQL 
ON P.TRANSFORM_GRPNAME = TO_SQL.TO_GRPNAME 
WHERE R.FUNCTION_TYPE NOT IN ('T', 'R') 
AND R.ROUTINESCHEMA <> 'SYSFUN';

CREATE VIEW "SYSIBM"."ROUTINES_S" ("SPECIFIC_CATALOG", "SPECIFIC_SCHEMA", "SPECIFIC_NAME", "ROUTINE_CATALOG", "ROUTINE_SCHEMA", "ROUTINE_NAME", "ROUTINE_TYPE", "MODULE_CATALOG", "MODULE_SCHEMA", "MODULE_NAME", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "DATA_TYPE", "CHAR_MAX_LENGTH", "CHAR_OCTET_LENGTH", "CHAR_SET_CATALOG", "CHAR_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PREC_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "TYPE_UDT_CATALOG", "TYPE_UDT_SCHEMA", "TYPE_UDT_NAME", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_NAME", "MAX_CARDINALITY", "DTD_IDENTIFIER", "ROUTINE_BODY", "ROUTINE_DEFINITION", "EXTERNAL_NAME", "EXTERNAL_LANGUAGE", "PARAMETER_STYLE", "IS_DETERMINISTIC", "SQL_DATA_ACCESS", "IS_NULL_CALL", "SQL_PATH", "SCH_LEVEL_ROUTINE", "MAX_DYN_RESLT_SETS", "IS_USER_DEFND_CAST", "IS_IMP_INVOCABLE", "SECURITY_TYPE", "TO_SQL_SPEC_CAT", "TO_SQL_SPEC_SCHEMA", "TO_SQL_SPEC_NAME", "AS_LOCATOR", "CREATED", "LAST_ALTERED") AS
SELECT 
SPECIFIC_CATALOG, SPECIFIC_SCHEMA, SPECIFIC_NAME, ROUTINE_CATALOG, 
ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, MODULE_CATALOG, 
MODULE_SCHEMA, MODULE_NAME, UDT_CATALOG, UDT_SCHEMA, 
UDT_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, 
CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, 
COLLATION_SCHEMA, COLLATION_NAME, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, 
NUMERIC_SCALE, DATETIME_PRECISION, INTERVAL_TYPE, INTERVAL_PRECISION, 
TYPE_UDT_CATALOG, TYPE_UDT_SCHEMA, TYPE_UDT_NAME, SCOPE_CATALOG, 
SCOPE_SCHEMA, SCOPE_NAME, MAXIMUM_CARDINALITY, DTD_IDENTIFIER, 
ROUTINE_BODY, ROUTINE_DEFINITION, EXTERNAL_NAME, EXTERNAL_LANGUAGE, 
PARAMETER_STYLE, IS_DETERMINISTIC, SQL_DATA_ACCESS, IS_NULL_CALL, 
SQL_PATH, SCHEMA_LEVEL_ROUTINE, MAX_DYNAMIC_RESULT_SETS, IS_USER_DEFINED_CAST, 
IS_IMPLICITLY_INVOCABLE, SECURITY_TYPE, TO_SQL_SPECIFIC_CATALOG, 
TO_SQL_SPECIFIC_SCHEMA, TO_SQL_SPECIFIC_NAME, AS_LOCATOR, CREATED, LAST_ALTERED 
FROM SYSIBM.ROUTINES;

CREATE VIEW "SYSIBM"."SQLCOLPRIVILEGES" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", "IS_GRANTABLE", "DBNAME") AS
SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(T.TCREATOR),     T.TTNAME,     C.NAME,     RTRIM(T.GRANTOR),     RTRIM(T.GRANTEE),     'REFERENCES',     CASE WHEN T.REFAUTH = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSTABAUTH T,     SYSIBM.SYSCOLUMNS C   WHERE     T.TCREATOR = C.TBCREATOR     AND T.TTNAME = C.TBNAME     AND T.REFAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(A.CREATOR),    A.TNAME,    C.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'REFERENCES',    CASE WHEN A.GRANTABLE='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSCOLAUTH A,    SYSIBM.SYSCOLUMNS C  WHERE    A.CREATOR=C.TBCREATOR    AND A.TNAME=C.TBNAME    AND A.COLNAME=C.NAME    AND A.PRIVTYPE='R' UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(T.TCREATOR),     T.TTNAME,     C.NAME,     RTRIM(T.GRANTOR),     RTRIM(T.GRANTEE),     'UPDATE',     CASE WHEN T.UPDATEAUTH = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSTABAUTH T,     SYSIBM.SYSCOLUMNS C   WHERE     T.TCREATOR = C.TBCREATOR     AND T.TTNAME = C.TBNAME     AND T.UPDATEAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(A.CREATOR),    A.TNAME,    C.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'UPDATE',    CASE WHEN A.GRANTABLE='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSCOLAUTH A,    SYSIBM.SYSCOLUMNS C  WHERE    A.CREATOR=C.TBCREATOR    AND A.TNAME=C.TBNAME    AND A.COLNAME=C.NAME    AND A.PRIVTYPE='U' UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.TCREATOR),    T.TTNAME,    C.NAME,    RTRIM(GRANTOR),    RTRIM(T.GRANTEE),    'SELECT',    CASE WHEN T.SELECTAUTH='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH T,    SYSIBM.SYSCOLUMNS C  WHERE    T.TCREATOR=C.TBCREATOR    AND T.TTNAME=C.TBNAME    AND T.SELECTAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.TCREATOR),    T.TTNAME,    C.NAME,    RTRIM(GRANTOR),    RTRIM(T.GRANTEE),    'INSERT',    CASE WHEN T.INSERTAUTH='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH T,    SYSIBM.SYSCOLUMNS C  WHERE    T.TCREATOR=C.TBCREATOR    AND T.TTNAME=C.TBNAME    AND T.INSERTAUTH IN ('Y', 'G') UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(Z.CREATOR),     Z.NAME,     C.NAME,     RTRIM(T.GRANTOR),     RTRIM(T.GRANTEE),     'REFERENCES',     CASE WHEN T.REFAUTH = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSTABAUTH T,     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABLES  Z,     TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B   WHERE     T.TCREATOR = C.TBCREATOR     AND T.TTNAME = C.TBNAME     AND T.REFAUTH IN ('Y', 'G')     AND Z.TYPE = 'A'     AND B.BASESCHEMA = T.TCREATOR     AND B.BASENAME = T.TTNAME UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(Z.CREATOR),     Z.NAME,     C.NAME,     RTRIM(A.GRANTOR),     RTRIM(A.GRANTEE),     'REFERENCES',     CASE WHEN A.GRANTABLE = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSCOLAUTH A,     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABLES  Z,     TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B   WHERE     A.CREATOR = C.TBCREATOR     AND A.TNAME = C.TBNAME     AND A.COLNAME=C.NAME     AND A.PRIVTYPE ='R'     AND Z.TYPE = 'A'     AND B.BASESCHEMA = A.CREATOR     AND B.BASENAME = A.TNAME UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(Z.CREATOR),     Z.NAME,     C.NAME,     RTRIM(T.GRANTOR),     RTRIM(T.GRANTEE),     'UPDATE',     CASE WHEN T.UPDATEAUTH = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSTABAUTH T,     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABLES  Z,     TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B   WHERE     T.TCREATOR = C.TBCREATOR     AND T.TTNAME = C.TBNAME     AND T.UPDATEAUTH IN ('Y', 'G')     AND Z.TYPE = 'A'     AND B.BASESCHEMA = T.TCREATOR     AND B.BASENAME = T.TTNAME UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(Z.CREATOR),     Z.NAME,     C.NAME,     RTRIM(A.GRANTOR),     RTRIM(A.GRANTEE),     'UPDATE',     CASE WHEN A.GRANTABLE = 'G' THEN 'YES' ELSE 'NO' END,     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSCOLAUTH A,     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABLES  Z,     TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B   WHERE     A.CREATOR = C.TBCREATOR     AND A.TNAME = C.TBNAME     AND A.COLNAME=C.NAME     AND A.PRIVTYPE ='U'     AND Z.TYPE = 'A'     AND B.BASESCHEMA = A.CREATOR     AND B.BASENAME = A.TNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(Z.CREATOR),    Z.NAME,    C.NAME,    RTRIM(GRANTOR),    RTRIM(T.GRANTEE),    'SELECT',    CASE WHEN T.SELECTAUTH='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH T,    SYSIBM.SYSCOLUMNS C,    SYSIBM.SYSTABLES  Z,    TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B  WHERE    T.TCREATOR=C.TBCREATOR    AND T.TTNAME=C.TBNAME    AND T.SELECTAUTH IN ('Y', 'G')    AND Z.TYPE = 'A'    AND B.BASESCHEMA = T.TCREATOR    AND B.BASENAME = T.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(Z.CREATOR),    Z.NAME,    C.NAME,    RTRIM(GRANTOR),    RTRIM(T.GRANTEE),    'INSERT',    CASE WHEN T.INSERTAUTH='G' THEN 'YES' ELSE 'NO' END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH T,    SYSIBM.SYSCOLUMNS C,    SYSIBM.SYSTABLES  Z,    TABLE(SYSPROC.BASE_TABLE(Z.CREATOR, Z.NAME)) AS B  WHERE    T.TCREATOR=C.TBCREATOR    AND T.TTNAME=C.TBNAME    AND T.INSERTAUTH IN ('Y', 'G')    AND Z.TYPE = 'A'    AND B.BASESCHEMA = T.TCREATOR    AND B.BASENAME = T.TTNAME;

CREATE VIEW "SYSIBM"."SQLCOLUMNS" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE", "JDBC_DATA_TYPE", "SCOPE_CATLOG", "SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE", "DBNAME", "PSEUDO_COLUMN") AS
WITH TYPEINTS ( TYPEINT, COLTYPE ) AS (  VALUES  ( SMALLINT(1 ), CHAR( 'INTEGER',  8) ),  ( SMALLINT(2 ), CHAR( 'SMALLINT', 8) ),  ( SMALLINT(3 ), CHAR( 'BIGINT',   8) ),  ( SMALLINT(4 ), CHAR( 'REAL',     8) ),  ( SMALLINT(5 ), CHAR( 'DOUBLE',   8) ),  ( SMALLINT(6 ), CHAR( 'CHAR',     8) ),  ( SMALLINT(7 ), CHAR( 'VARCHAR',  8) ),  ( SMALLINT(8 ), CHAR( 'LONGVAR',  8) ),  ( SMALLINT(9 ), CHAR( 'DECIMAL',  8) ),  ( SMALLINT(10), CHAR( 'GRAPHIC',  8) ),  ( SMALLINT(11), CHAR( 'VARGRAPH', 8) ),  ( SMALLINT(12), CHAR( 'LONGVARG', 8) ),  ( SMALLINT(13), CHAR( 'BLOB',     8) ),  ( SMALLINT(14), CHAR( 'CLOB',     8) ),  ( SMALLINT(15), CHAR( 'DBCLOB',   8) ),  ( SMALLINT(16), CHAR( 'DATE',     8) ),  ( SMALLINT(17), CHAR( 'TIME',     8) ),  ( SMALLINT(18), CHAR( 'TIMESTMP', 8) ),  ( SMALLINT(19), CHAR( 'DATALINK', 8) ),  ( SMALLINT(20), CHAR( 'STRUCT',   8) ),  ( SMALLINT(21), CHAR( 'DISTINCT', 8) ),  ( SMALLINT(22), CHAR( 'REF',      8) ),  ( SMALLINT(23), CHAR( 'XML',      8) ) )   SELECT CAST( NULL AS VARCHAR(128) ), RTRIM(C.TBCREATOR), C.TBNAME, C.NAME, SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN -5   WHEN I.TYPEINT=4 THEN 7   WHEN I.TYPEINT=5 THEN 8    WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4   WHEN I.TYPEINT=9 THEN 3   WHEN I.TYPEINT=10 THEN -95   WHEN I.TYPEINT=11 THEN -96   WHEN I.TYPEINT=12 THEN -97   WHEN I.TYPEINT=13 THEN -98   WHEN I.TYPEINT=14 THEN -99   WHEN I.TYPEINT=15 THEN -350   WHEN I.TYPEINT=16 THEN 91   WHEN I.TYPEINT=17 THEN 92   WHEN I.TYPEINT=18 THEN 93   WHEN I.TYPEINT=19 THEN -400   WHEN I.TYPEINT=20 THEN 17   WHEN I.TYPEINT=21 THEN 17   WHEN I.TYPEINT=23 THEN -370   ELSE 0 END),  CAST( CASE   WHEN I.TYPEINT=1 THEN 'INTEGER'   WHEN I.TYPEINT=2 THEN 'SMALLINT'   WHEN I.TYPEINT=3 THEN 'BIGINT'   WHEN I.TYPEINT=4 THEN 'REAL'   WHEN I.TYPEINT=5 THEN 'DOUBLE'   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 THEN 'CHAR'   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 THEN 'CHAR () FOR BIT DATA'   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 'VARCHAR'   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN 'VARCHAR () FOR BIT DATA'   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN 'LONG VARCHAR'   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN 'LONG VARCHAR FOR BIT DATA'   WHEN I.TYPEINT=9 THEN 'DECIMAL'   WHEN I.TYPEINT=10 THEN 'GRAPHIC'   WHEN I.TYPEINT=11 THEN 'VARGRAPHIC'   WHEN I.TYPEINT=12 THEN 'LONG VARGRAPHIC'   WHEN I.TYPEINT=13 THEN 'BLOB'   WHEN I.TYPEINT=14 THEN 'CLOB'   WHEN I.TYPEINT=15 THEN 'DBCLOB'   WHEN I.TYPEINT=16 THEN 'DATE'   WHEN I.TYPEINT=17 THEN 'TIME'   WHEN I.TYPEINT=18 THEN 'TIMESTAMP'   WHEN I.TYPEINT=19 THEN 'DATALINK'   WHEN I.TYPEINT=20 THEN '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'   WHEN I.TYPEINT=21 THEN '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'   WHEN I.TYPEINT=23 THEN 'XML'   ELSE '' END AS VARCHAR(261) ),  CASE   WHEN I.TYPEINT=1 THEN 10   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN 19   WHEN I.TYPEINT=4 THEN 24   WHEN I.TYPEINT=5 THEN 53   WHEN I.TYPEINT=6 THEN C.LENGTH   WHEN I.TYPEINT=7 THEN C.LENGTH   WHEN I.TYPEINT=8 THEN C.LENGTH   WHEN I.TYPEINT=9 THEN C.LENGTH   WHEN I.TYPEINT=10 THEN C.LENGTH   WHEN I.TYPEINT=11 THEN C.LENGTH   WHEN I.TYPEINT=12 THEN C.LENGTH   WHEN I.TYPEINT=13 THEN C.LONGLENGTH   WHEN I.TYPEINT=14 THEN C.LONGLENGTH   WHEN I.TYPEINT=15 THEN C.LONGLENGTH   WHEN I.TYPEINT=16 THEN 10   WHEN I.TYPEINT=17 THEN 8    WHEN I.TYPEINT=18 THEN    CASE WHEN C.SCALE=0 THEN 19         ELSE 20+C.SCALE    END   WHEN I.TYPEINT=20 THEN D.LENGTH   WHEN I.TYPEINT=21 THEN D.LENGTH   WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE C.LENGTH END,  CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 2   WHEN I.TYPEINT=3 THEN 8   WHEN I.TYPEINT=4 THEN 4   WHEN I.TYPEINT=5 THEN 8   WHEN I.TYPEINT=6 THEN C.LENGTH   WHEN I.TYPEINT=7 THEN C.LENGTH   WHEN I.TYPEINT=8 THEN C.LENGTH   WHEN I.TYPEINT=9 THEN C.LENGTH + 2   WHEN I.TYPEINT=10 THEN C.LENGTH * 2   WHEN I.TYPEINT=11 THEN C.LENGTH * 2   WHEN I.TYPEINT=12 THEN C.LENGTH * 2   WHEN I.TYPEINT=13 THEN C.LONGLENGTH   WHEN I.TYPEINT=14 THEN C.LONGLENGTH   WHEN I.TYPEINT=15 THEN C.LONGLENGTH * 2   WHEN I.TYPEINT=16 THEN 6   WHEN I.TYPEINT=17 THEN 6   WHEN I.TYPEINT=18 THEN 16   WHEN I.TYPEINT=19 THEN C.LENGTH   WHEN I.TYPEINT=20        AND D.SOURCETYPE          NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH   WHEN I.TYPEINT=20        AND D.SOURCETYPE          IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2   WHEN I.TYPEINT=21        AND D.SOURCETYPE          NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH   WHEN I.TYPEINT=21        AND D.SOURCETYPE          IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2    WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE C.LENGTH END,  SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 0   WHEN I.TYPEINT=2 THEN 0   WHEN I.TYPEINT=3 THEN 0   WHEN I.TYPEINT=4 THEN NULL   WHEN I.TYPEINT=5 THEN NULL   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN C.SCALE   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN NULL   WHEN I.TYPEINT=17 THEN 0   WHEN I.TYPEINT=18 THEN C.SCALE   WHEN I.TYPEINT=19 THEN NULL   WHEN I.TYPEINT=20         AND D.SOURCETYPE='DECIMAL'        THEN D.SCALE   WHEN I.TYPEINT=20        AND D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')        THEN 0   WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIMESTAMP'        THEN D.SCALE    WHEN I.TYPEINT=21        AND D.SOURCETYPE='DECIMAL'        THEN D.SCALE    WHEN I.TYPEINT=21        AND D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')        THEN 0    WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIMESTAMP'        THEN D.SCALE   WHEN I.TYPEINT=23 THEN NULL   ELSE NULL END ),     SMALLINT(CASE   WHEN I.TYPEINT=1 THEN 10    WHEN I.TYPEINT=2 THEN 10   WHEN I.TYPEINT=3 THEN 10   WHEN I.TYPEINT=4 THEN 2   WHEN I.TYPEINT=5 THEN 2   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN 10   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN NULL   WHEN I.TYPEINT=17 THEN NULL   WHEN I.TYPEINT=18 THEN NULL   WHEN I.TYPEINT=19 THEN NULL   WHEN I.TYPEINT=20        AND D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')        THEN 10   WHEN I.TYPEINT=20        AND D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')        THEN 2   WHEN I.TYPEINT=21        AND D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')        THEN 10   WHEN I.TYPEINT=21         AND D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')        THEN 2   WHEN I.TYPEINT=23 THEN NULL   ELSE NULL END),    SMALLINT(CASE    WHEN C.NULLS='Y' THEN 1 ELSE 0 END), C.REMARKS, C.DEFAULT, SMALLINT(CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 5    WHEN I.TYPEINT=3 THEN -5   WHEN I.TYPEINT=4 THEN 7   WHEN I.TYPEINT=5 THEN 8   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1    WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2    WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4   WHEN I.TYPEINT=9 THEN 3   WHEN I.TYPEINT=10 THEN -95   WHEN I.TYPEINT=11 THEN -96   WHEN I.TYPEINT=12 THEN -97   WHEN I.TYPEINT=13 THEN -98   WHEN I.TYPEINT=14 THEN -99   WHEN I.TYPEINT=15 THEN -350   WHEN I.TYPEINT=16 THEN 9   WHEN I.TYPEINT=17 THEN 9   WHEN I.TYPEINT=18 THEN 9   WHEN I.TYPEINT=19 THEN -400   WHEN I.TYPEINT=20 THEN 17   WHEN I.TYPEINT=21 THEN 17   WHEN I.TYPEINT=23 THEN -370   ELSE 0 END),    SMALLINT(CASE   WHEN I.TYPEINT=1 THEN NULL   WHEN I.TYPEINT=2 THEN NULL   WHEN I.TYPEINT=3 THEN NULL   WHEN I.TYPEINT=4 THEN NULL   WHEN I.TYPEINT=5 THEN NULL   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN NULL   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN 1   WHEN I.TYPEINT=17 THEN 2   WHEN I.TYPEINT=18 THEN 3   WHEN I.TYPEINT=19 THEN NULL   WHEN I.TYPEINT=20        AND D.SOURCETYPE='DATE' THEN 1   WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIME' THEN 2   WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIMESTAMP' THEN 3   WHEN I.TYPEINT=21        AND D.SOURCETYPE='DATE' THEN 1    WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIME' THEN 2   WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIMESTAMP' THEN 3   WHEN I.TYPEINT=23 THEN NULL   ELSE NULL END),     CASE WHEN I.TYPEINT=1 THEN NULL WHEN I.TYPEINT=2 THEN NULL WHEN I.TYPEINT=3 THEN NULL WHEN I.TYPEINT=4 THEN NULL WHEN I.TYPEINT=5 THEN NULL WHEN I.TYPEINT=6 THEN C.LENGTH WHEN I.TYPEINT=7 THEN C.LENGTH WHEN I.TYPEINT=8 THEN C.LENGTH WHEN I.TYPEINT=9 THEN NULL WHEN I.TYPEINT=10 THEN C.LENGTH * 2 WHEN I.TYPEINT=11 THEN C.LENGTH * 2 WHEN I.TYPEINT=12 THEN C.LENGTH * 2 WHEN I.TYPEINT=13 THEN C.LONGLENGTH WHEN I.TYPEINT=14 THEN C.LONGLENGTH WHEN I.TYPEINT=15 THEN C.LONGLENGTH * 2  WHEN I.TYPEINT=16 THEN NULL WHEN I.TYPEINT=17 THEN NULL WHEN I.TYPEINT=18 THEN NULL WHEN I.TYPEINT=19 THEN NULL WHEN I.TYPEINT=20      AND D.SOURCETYPE IN      ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB')      THEN D.LENGTH WHEN I.TYPEINT=20      AND D.SOURCETYPE IN      ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')      THEN D.LENGTH * 2 WHEN I.TYPEINT=21      AND D.SOURCETYPE IN      ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB')      THEN D.LENGTH    WHEN I.TYPEINT=21        AND D.SOURCETYPE IN        ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2   WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE NULL END, C.COLNO + 1, CASE   WHEN C.NULLS='Y' THEN 'YES' ELSE 'NO' END, SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN -5   WHEN I.TYPEINT=4 THEN 7   WHEN I.TYPEINT=5 THEN 8   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4   WHEN I.TYPEINT=9 THEN 3   WHEN I.TYPEINT=10 THEN 1   WHEN I.TYPEINT=11 THEN 12   WHEN I.TYPEINT=12 THEN -1   WHEN I.TYPEINT=13 THEN 2004   WHEN I.TYPEINT=14 THEN 2005   WHEN I.TYPEINT=15 THEN 2005   WHEN I.TYPEINT=16 THEN 91  WHEN I.TYPEINT=17 THEN 92   WHEN I.TYPEINT=18 THEN 93   WHEN I.TYPEINT=19 THEN 70   WHEN I.TYPEINT=20 THEN 2002   WHEN I.TYPEINT=21 THEN 2001   WHEN I.TYPEINT=23 THEN 1111   ELSE 0 END), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), SMALLINT( CASE   WHEN D.SOURCETYPE IS NULL THEN NULL   WHEN D.SOURCETYPE='INTEGER' THEN 4   WHEN D.SOURCETYPE='SMALLINT' THEN 5   WHEN D.SOURCETYPE='BIGINT' THEN -5   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=4 THEN 7   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=8 THEN 8   WHEN D.SOURCETYPE='REAL' THEN 7   WHEN D.SOURCETYPE='DOUBLE' THEN 8   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE <> 0 then 1   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE = 0 then -2   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE <> 0 THEN 12   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE = 0 THEN -3   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE <> 0 THEN -1   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE = 0 THEN -4   WHEN D.SOURCETYPE='DECIMAL' THEN 3   WHEN D.SOURCETYPE='GRAPHIC' THEN -95   WHEN D.SOURCETYPE='VARGRAPHIC' THEN -96   WHEN D.SOURCETYPE='LONG VARGRAPHIC' THEN -97   WHEN D.SOURCETYPE='BLOB' THEN -98   WHEN D.SOURCETYPE='CLOB' THEN -99   WHEN D.SOURCETYPE='DBCLOB' THEN -350   WHEN D.SOURCETYPE='DATE' THEN 91   WHEN D.SOURCETYPE='TIME' THEN 92   WHEN D.SOURCETYPE='TIMESTAMP' THEN 93   WHEN D.SOURCETYPE='DATALINK' THEN -400   WHEN D.SOURCETYPE='XML' THEN -370   ELSE 0     END), CAST( NULL AS VARCHAR(8) ), SMALLINT(CASE   WHEN C.IDENTITY = 'Y' THEN 2   ELSE 1 END ) FROM   SYSIBM.SYSCOLUMNS C,   SYSIBM.SYSDATATYPES D,   TYPEINTS I WHERE   C.COLTYPE <> 'REF'   AND I.TYPEINT <> 22   AND C.TYPENAME = D.NAME   AND C.TYPESCHEMA = D.SCHEMA   AND C.COLTYPE = I.COLTYPE    UNION ALL SELECT   CAST( NULL AS VARCHAR(128) ),   RTRIM(C.TBCREATOR),   C.TBNAME,   C.NAME,   SMALLINT(20),   CAST( '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'         AS VARCHAR(261) ),   CASE     WHEN D.SOURCETYPE = 'REAL' THEN 24     WHEN D.SOURCETYPE = 'DOUBLE' THEN 53     ELSE D.LENGTH   END,   CASE     WHEN D.SOURCETYPE            NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')          THEN D.LENGTH     WHEN D.SOURCETYPE            IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')          THEN D.LENGTH * 2     ELSE NULL   END,   SMALLINT( CASE     WHEN D.SOURCETYPE='DECIMAL'          THEN D.SCALE     WHEN D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')          THEN 0     WHEN D.SOURCETYPE='TIMESTAMP'          THEN 6     ELSE NULL   END ),   SMALLINT( CASE     WHEN D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')          THEN 10     WHEN D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')          THEN 2     ELSE NULL   END),    SMALLINT(CASE    WHEN C.NULLS='Y' THEN 1 ELSE 0 END), C.REMARKS, C.DEFAULT, SMALLINT( 20 ), SMALLINT( CASE   WHEN D.SOURCETYPE='DATE' THEN 1   WHEN D.SOURCETYPE='TIME' THEN 2   WHEN D.SOURCETYPE='TIMESTAMP' THEN 3   ELSE NULL END), CASE   WHEN D.SOURCETYPE IN        ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB','XML')        THEN D.LENGTH   WHEN D.SOURCETYPE IN        ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2   ELSE NULL END, C.COLNO + 1, CASE   WHEN C.NULLS='Y' THEN 'YES' ELSE 'NO' END, SMALLINT( 2006 ), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), SMALLINT( CASE   WHEN D.SOURCETYPE IS NULL THEN NULL   WHEN D.SOURCETYPE='INTEGER' THEN 4   WHEN D.SOURCETYPE='SMALLINT' THEN 5   WHEN D.SOURCETYPE='BIGINT' THEN -5   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=4 THEN 7   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=8 THEN 8   WHEN D.SOURCETYPE='REAL' THEN 7   WHEN D.SOURCETYPE='DOUBLE' THEN 8   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE <> 0 then 1   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE = 0 then -2   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE <> 0 THEN 12   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE = 0 THEN -3   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE <> 0 THEN -1   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE = 0 THEN -4   WHEN D.SOURCETYPE='DECIMAL' THEN 3   WHEN D.SOURCETYPE='GRAPHIC' THEN -95   WHEN D.SOURCETYPE='VARGRAPHIC' THEN -96   WHEN D.SOURCETYPE='LONG VARGRAPHIC' THEN -97   WHEN D.SOURCETYPE='BLOB' THEN -98   WHEN D.SOURCETYPE='CLOB' THEN -99   WHEN D.SOURCETYPE='DBCLOB' THEN -350   WHEN D.SOURCETYPE='DATE' THEN 91   WHEN D.SOURCETYPE='TIME' THEN 92   WHEN D.SOURCETYPE='TIMESTAMP' THEN 93   WHEN D.SOURCETYPE='DATALINK' THEN -400   WHEN D.SOURCETYPE='XML' THEN -370   ELSE 0 END ), CAST( NULL AS VARCHAR(8) ), SMALLINT(1) FROM   SYSIBM.SYSCOLUMNS C,   SYSIBM.SYSDATATYPES D,   SYSIBM.SYSCOLPROPERTIES P,   TYPEINTS I WHERE   C.COLTYPE = 'REF'   AND I.TYPEINT = 22   AND P.COLNAME = C.NAME   AND P.TABSCHEMA = C.TBCREATOR    AND P.TABNAME = C.TBNAME   AND P.TARGET_TYPENAME = D.NAME   AND P.TARGET_TYPESCHEMA = D.SCHEMA   AND C.COLTYPE = I.COLTYPE  UNION ALL  SELECT CAST( NULL AS VARCHAR(128) ), RTRIM(T.CREATOR), T.NAME, C.NAME, SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN -5   WHEN I.TYPEINT=4 THEN 7   WHEN I.TYPEINT=5 THEN 8   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4   WHEN I.TYPEINT=9 THEN 3   WHEN I.TYPEINT=10 THEN -95   WHEN I.TYPEINT=11 THEN -96   WHEN I.TYPEINT=12 THEN -97   WHEN I.TYPEINT=13 THEN -98   WHEN I.TYPEINT=14 THEN -99   WHEN I.TYPEINT=15 THEN -350   WHEN I.TYPEINT=16 THEN 91   WHEN I.TYPEINT=17 THEN 92   WHEN I.TYPEINT=18 THEN 93   WHEN I.TYPEINT=19 THEN -400   WHEN I.TYPEINT=20 THEN 17   WHEN I.TYPEINT=21 THEN 17   WHEN I.TYPEINT=23 THEN -370   ELSE 0 END),    CAST( CASE   WHEN I.TYPEINT=1 THEN 'INTEGER'   WHEN I.TYPEINT=2 THEN 'SMALLINT'   WHEN I.TYPEINT=3 THEN 'BIGINT'   WHEN I.TYPEINT=4 THEN 'REAL'   WHEN I.TYPEINT=5 THEN 'DOUBLE'   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 THEN 'CHAR'   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 THEN 'CHAR () FOR BIT DATA'   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 'VARCHAR'   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN 'VARCHAR () FOR BIT DATA'   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN 'LONG VARCHAR'   WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN 'LONG VARCHAR FOR BIT DATA'   WHEN I.TYPEINT=9 THEN 'DECIMAL'   WHEN I.TYPEINT=10 THEN 'GRAPHIC'   WHEN I.TYPEINT=11 THEN 'VARGRAPHIC'   WHEN I.TYPEINT=12 THEN 'LONG VARGRAPHIC'   WHEN I.TYPEINT=13 THEN 'BLOB'   WHEN I.TYPEINT=14 THEN 'CLOB'   WHEN I.TYPEINT=15 THEN 'DBCLOB'   WHEN I.TYPEINT=16 THEN 'DATE'   WHEN I.TYPEINT=17 THEN 'TIME'   WHEN I.TYPEINT=18 THEN 'TIMESTAMP'   WHEN I.TYPEINT=19 THEN 'DATALINK'   WHEN I.TYPEINT=20 THEN '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'   WHEN I.TYPEINT=21 THEN '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'   WHEN I.TYPEINT=23 THEN 'XML'   ELSE '' END  AS VARCHAR(261) ),  CASE   WHEN I.TYPEINT=1 THEN 10   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN 19    WHEN I.TYPEINT=4 THEN 24   WHEN I.TYPEINT=5 THEN 53   WHEN I.TYPEINT=6 THEN C.LENGTH   WHEN I.TYPEINT=7 THEN C.LENGTH   WHEN I.TYPEINT=8 THEN C.LENGTH   WHEN I.TYPEINT=9 THEN C.LENGTH   WHEN I.TYPEINT=10 THEN C.LENGTH   WHEN I.TYPEINT=11 THEN C.LENGTH   WHEN I.TYPEINT=12 THEN C.LENGTH   WHEN I.TYPEINT=13 THEN C.LONGLENGTH   WHEN I.TYPEINT=14 THEN C.LONGLENGTH   WHEN I.TYPEINT=15 THEN C.LONGLENGTH   WHEN I.TYPEINT=16 THEN 10   WHEN I.TYPEINT=17 THEN 8    WHEN I.TYPEINT=18 THEN    CASE WHEN C.SCALE=0 THEN 19         ELSE 20+C.SCALE    END   WHEN I.TYPEINT=20 THEN D.LENGTH   WHEN I.TYPEINT=21 THEN D.LENGTH   WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE C.LENGTH END,  CASE WHEN I.TYPEINT=1 THEN 4 WHEN I.TYPEINT=2 THEN 2 WHEN I.TYPEINT=3 THEN 8 WHEN I.TYPEINT=4 THEN 4 WHEN I.TYPEINT=5 THEN 8 WHEN I.TYPEINT=6 THEN C.LENGTH WHEN I.TYPEINT=7 THEN C.LENGTH WHEN I.TYPEINT=8 THEN C.LENGTH WHEN I.TYPEINT=9 THEN C.LENGTH + 2 WHEN I.TYPEINT=10 THEN C.LENGTH * 2 WHEN I.TYPEINT=11 THEN C.LENGTH * 2 WHEN I.TYPEINT=12 THEN C.LENGTH * 2 WHEN I.TYPEINT=13 THEN C.LONGLENGTH WHEN I.TYPEINT=14 THEN C.LONGLENGTH WHEN I.TYPEINT=15 THEN C.LONGLENGTH * 2 WHEN I.TYPEINT=16 THEN 6 WHEN I.TYPEINT=17 THEN 6 WHEN I.TYPEINT=18 THEN 16 WHEN I.TYPEINT=19 THEN C.LENGTH WHEN I.TYPEINT=20      AND D.SOURCETYPE        NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')      THEN D.LENGTH WHEN I.TYPEINT=20      AND D.SOURCETYPE        IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')      THEN D.LENGTH * 2 WHEN I.TYPEINT=21      AND D.SOURCETYPE        NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')      THEN D.LENGTH  WHEN I.TYPEINT=21        AND D.SOURCETYPE          IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2 WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE C.LENGTH END, SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 0   WHEN I.TYPEINT=2 THEN 0   WHEN I.TYPEINT=3 THEN 0   WHEN I.TYPEINT=4 THEN NULL   WHEN I.TYPEINT=5 THEN NULL   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN C.SCALE   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN NULL    WHEN I.TYPEINT=17 THEN 0   WHEN I.TYPEINT=18 THEN C.SCALE   WHEN I.TYPEINT=19 THEN NULL   WHEN I.TYPEINT=20        AND D.SOURCETYPE='DECIMAL'        THEN D.SCALE   WHEN I.TYPEINT=20        AND D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')        THEN 0  WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIMESTAMP'        THEN D.SCALE   WHEN I.TYPEINT=21        AND D.SOURCETYPE='DECIMAL'        THEN D.SCALE   WHEN I.TYPEINT=21        AND D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')        THEN 0   WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIMESTAMP'        THEN D.SCALE   WHEN I.TYPEINT=23 THEN NULL   ELSE NULL END ), SMALLINT(CASE   WHEN I.TYPEINT=1 THEN 10   WHEN I.TYPEINT=2 THEN 10   WHEN I.TYPEINT=3 THEN 10   WHEN I.TYPEINT=4 THEN 2   WHEN I.TYPEINT=5 THEN 2   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN 10   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN NULL   WHEN I.TYPEINT=17 THEN NULL   WHEN I.TYPEINT=18 THEN NULL   WHEN I.TYPEINT=19 THEN NULL  WHEN I.TYPEINT=20         AND D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')         THEN 10    WHEN I.TYPEINT=20         AND D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')         THEN 2    WHEN I.TYPEINT=21         AND D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')         THEN 10    WHEN I.TYPEINT=21         AND D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')         THEN 2    WHEN I.TYPEINT=23 THEN NULL    ELSE NULL  END),  SMALLINT(CASE     WHEN C.NULLS='Y' THEN 1 ELSE 0  END),  C.REMARKS,  C.DEFAULT,  SMALLINT(CASE    WHEN I.TYPEINT=1 THEN 4    WHEN I.TYPEINT=2 THEN 5    WHEN I.TYPEINT=3 THEN -5    WHEN I.TYPEINT=4 THEN 7    WHEN I.TYPEINT=5 THEN 8     WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1    WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2    WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12    WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3    WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1    WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4    WHEN I.TYPEINT=9 THEN 3  WHEN I.TYPEINT=10 THEN -95   WHEN I.TYPEINT=11 THEN -96   WHEN I.TYPEINT=12 THEN -97   WHEN I.TYPEINT=13 THEN -98   WHEN I.TYPEINT=14 THEN -99   WHEN I.TYPEINT=15 THEN -350   WHEN I.TYPEINT=16 THEN 9   WHEN I.TYPEINT=17 THEN 9   WHEN I.TYPEINT=18 THEN 9   WHEN I.TYPEINT=19 THEN -400   WHEN I.TYPEINT=20 THEN 17   WHEN I.TYPEINT=21 THEN 17   WHEN I.TYPEINT=23 THEN -370   ELSE 0 END), SMALLINT(CASE   WHEN I.TYPEINT=1 THEN NULL   WHEN I.TYPEINT=2 THEN NULL   WHEN I.TYPEINT=3 THEN NULL   WHEN I.TYPEINT=4 THEN NULL   WHEN I.TYPEINT=5 THEN NULL   WHEN I.TYPEINT=6 THEN NULL   WHEN I.TYPEINT=7 THEN NULL   WHEN I.TYPEINT=8 THEN NULL   WHEN I.TYPEINT=9 THEN NULL   WHEN I.TYPEINT=10 THEN NULL   WHEN I.TYPEINT=11 THEN NULL   WHEN I.TYPEINT=12 THEN NULL   WHEN I.TYPEINT=13 THEN NULL   WHEN I.TYPEINT=14 THEN NULL   WHEN I.TYPEINT=15 THEN NULL   WHEN I.TYPEINT=16 THEN 1   WHEN I.TYPEINT=17 THEN 2   WHEN I.TYPEINT=18 THEN 3   WHEN I.TYPEINT=19 THEN NULL  WHEN I.TYPEINT=20        AND D.SOURCETYPE='DATE' THEN 1   WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIME' THEN 2   WHEN I.TYPEINT=20        AND D.SOURCETYPE='TIMESTAMP' THEN 3   WHEN I.TYPEINT=21        AND D.SOURCETYPE='DATE' THEN 1   WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIME' THEN 2   WHEN I.TYPEINT=21        AND D.SOURCETYPE='TIMESTAMP' THEN 3   WHEN I.TYPEINT=23 THEN NULL   ELSE NULL END), CASE    WHEN I.TYPEINT=6 THEN C.LENGTH   WHEN I.TYPEINT=7 THEN C.LENGTH   WHEN I.TYPEINT=8 THEN C.LENGTH   WHEN I.TYPEINT=10 THEN C.LENGTH * 2   WHEN I.TYPEINT=11 THEN C.LENGTH * 2   WHEN I.TYPEINT=12 THEN C.LENGTH * 2   WHEN I.TYPEINT=13 THEN C.LONGLENGTH   WHEN I.TYPEINT=14 THEN C.LONGLENGTH   WHEN I.TYPEINT=15 THEN C.LONGLENGTH * 2   WHEN I.TYPEINT=20        AND D.SOURCETYPE IN        ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB','XML')        THEN D.LENGTH       WHEN I.TYPEINT=20        AND D.SOURCETYPE IN        ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2   WHEN I.TYPEINT=21        AND D.SOURCETYPE IN        ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB')        THEN D.LENGTH   WHEN I.TYPEINT=21        AND D.SOURCETYPE IN        ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')        THEN D.LENGTH * 2   WHEN I.TYPEINT=23 THEN C.LONGLENGTH   ELSE NULL END, C.COLNO + 1, CASE    WHEN C.NULLS='Y' THEN 'YES' ELSE 'NO' END, SMALLINT( CASE   WHEN I.TYPEINT=1 THEN 4   WHEN I.TYPEINT=2 THEN 5   WHEN I.TYPEINT=3 THEN -5   WHEN I.TYPEINT=4 THEN 7   WHEN I.TYPEINT=5 THEN 8   WHEN I.TYPEINT=6 AND C.CODEPAGE <> 0 then 1   WHEN I.TYPEINT=6 AND C.CODEPAGE = 0 then -2   WHEN I.TYPEINT=7 AND C.CODEPAGE <> 0 THEN 12   WHEN I.TYPEINT=7 AND C.CODEPAGE = 0 THEN -3   WHEN I.TYPEINT=8 AND C.CODEPAGE <> 0 THEN -1  WHEN I.TYPEINT=8 AND C.CODEPAGE = 0 THEN -4   WHEN I.TYPEINT=9 THEN 3   WHEN I.TYPEINT=10 THEN 1   WHEN I.TYPEINT=11 THEN 12   WHEN I.TYPEINT=12 THEN -1   WHEN I.TYPEINT=13 THEN 2004   WHEN I.TYPEINT=14 THEN 2005   WHEN I.TYPEINT=15 THEN 2005   WHEN I.TYPEINT=16 THEN 91   WHEN I.TYPEINT=17 THEN 92   WHEN I.TYPEINT=18 THEN 93   WHEN I.TYPEINT=19 THEN 70   WHEN I.TYPEINT=20 THEN 2002   WHEN I.TYPEINT=21 THEN 2001   WHEN I.TYPEINT=23 THEN 1111   ELSE 0  END), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), CAST( NULL AS VARCHAR(128) ), SMALLINT( CASE   WHEN D.SOURCETYPE IS NULL THEN NULL   WHEN D.SOURCETYPE='INTEGER' THEN 4   WHEN D.SOURCETYPE='SMALLINT' THEN 5   WHEN D.SOURCETYPE='BIGINT' THEN -5   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=4 THEN 7   WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=8 THEN 8   WHEN D.SOURCETYPE='REAL' THEN 7   WHEN D.SOURCETYPE='DOUBLE' THEN 8   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE <> 0 then 1   WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE = 0 then -2   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE <> 0 THEN 12   WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE = 0 THEN -3   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE <> 0 THEN -1   WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE = 0 THEN -4   WHEN D.SOURCETYPE='DECIMAL' THEN 3   WHEN D.SOURCETYPE='GRAPHIC' THEN -95   WHEN D.SOURCETYPE='VARGRAPHIC' THEN -96   WHEN D.SOURCETYPE='LONG VARGRAPHIC' THEN -97   WHEN D.SOURCETYPE='BLOB' THEN -98   WHEN D.SOURCETYPE='CLOB' THEN -99   WHEN D.SOURCETYPE='DBCLOB' THEN -350   WHEN D.SOURCETYPE='DATE' THEN 91   WHEN D.SOURCETYPE='TIME' THEN 92   WHEN D.SOURCETYPE='TIMESTAMP' THEN 93   WHEN D.SOURCETYPE='DATALINK' THEN -400   WHEN D.SOURCETYPE='XML' THEN -370   ELSE 0 END ), CAST( NULL AS VARCHAR(8) ), SMALLINT(CASE   WHEN C.IDENTITY = 'Y' THEN 2   ELSE 1 END ) FROM   SYSIBM.SYSCOLUMNS C,   SYSIBM.SYSDATATYPES D,   SYSIBM.SYSTABLES T,   TYPEINTS I,   TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B WHERE   C.COLTYPE <> 'REF'   AND I.TYPEINT <> 22    AND C.TYPENAME = D.NAME   AND C.TYPESCHEMA = D.SCHEMA   AND T.TYPE = 'A'   AND B.BASESCHEMA = C.TBCREATOR   AND B.BASENAME = C.TBNAME   AND C.COLTYPE = I.COLTYPE UNION ALL  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    C.NAME,    SMALLINT(20),    CAST( '"' || RTRIM(D.SCHEMA) || '"."' || D.NAME || '"'          AS VARCHAR(261) ),    CASE      WHEN D.SOURCETYPE = 'REAL' THEN 24      WHEN D.SOURCETYPE = 'DOUBLE' THEN 53      ELSE D.LENGTH    END,    CASE      WHEN D.SOURCETYPE             NOT IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')           THEN D.LENGTH      WHEN D.SOURCETYPE             IN ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')           THEN D.LENGTH * 2      ELSE NULL    END,    SMALLINT( CASE      WHEN D.SOURCETYPE='DECIMAL'           THEN D.SCALE      WHEN D.SOURCETYPE IN ('INTEGER','SMALLINT','BIGINT','TIME')           THEN 0      WHEN D.SOURCETYPE='TIMESTAMP'           THEN 6      ELSE NULL    END ),     SMALLINT( CASE      WHEN D.SOURCETYPE IN ('DECIMAL','INTEGER','SMALLINT','BIGINT')           THEN 10      WHEN D.SOURCETYPE IN ('REAL','FLOAT','DOUBLE')           THEN 2      ELSE NULL    END),   SMALLINT(CASE       WHEN C.NULLS='Y' THEN 1 ELSE 0     END),    C.REMARKS,    C.DEFAULT,    SMALLINT( 20 ),   SMALLINT( CASE      WHEN D.SOURCETYPE='DATE' THEN 1      WHEN D.SOURCETYPE='TIME' THEN 2      WHEN D.SOURCETYPE='TIMESTAMP' THEN 3      ELSE NULL    END),    CASE      WHEN D.SOURCETYPE IN           ('CHARACTER','VARCHAR','LONG VARCHAR','BLOB','CLOB','XML')           THEN D.LENGTH      WHEN D.SOURCETYPE IN           ('GRAPHIC','VARGRAPHIC','LONG VARGRAPHIC','DBCLOB')           THEN D.LENGTH * 2      ELSE NULL    END,    C.COLNO + 1,  CASE      WHEN C.NULLS='Y' THEN 'YES' ELSE 'NO'    END,    SMALLINT( 2006 ),    CAST( NULL AS VARCHAR(128) ),    CAST( NULL AS VARCHAR(128) ),    CAST( NULL AS VARCHAR(128) ),    SMALLINT( CASE      WHEN D.SOURCETYPE IS NULL THEN NULL      WHEN D.SOURCETYPE='INTEGER' THEN 4      WHEN D.SOURCETYPE='SMALLINT' THEN 5      WHEN D.SOURCETYPE='BIGINT' THEN -5      WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=4 THEN 7      WHEN D.SOURCETYPE='FLOAT' AND C.LENGTH=8 THEN 8      WHEN D.SOURCETYPE='REAL' THEN 7      WHEN D.SOURCETYPE='DOUBLE' THEN 8      WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE <> 0 then 1      WHEN D.SOURCETYPE='CHARACTER' AND C.CODEPAGE = 0 then -2      WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE <> 0 THEN 12      WHEN D.SOURCETYPE='VARCHAR' AND C.CODEPAGE = 0 THEN -3      WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE <> 0 THEN -1      WHEN D.SOURCETYPE='LONG VARCHAR' AND C.CODEPAGE = 0 THEN -4      WHEN D.SOURCETYPE='DECIMAL' THEN 3      WHEN D.SOURCETYPE='GRAPHIC' THEN -95      WHEN D.SOURCETYPE='VARGRAPHIC' THEN -96      WHEN D.SOURCETYPE='LONG VARGRAPHIC' THEN -97      WHEN D.SOURCETYPE='BLOB' THEN -98      WHEN D.SOURCETYPE='CLOB' THEN -99      WHEN D.SOURCETYPE='DBCLOB' THEN -350      WHEN D.SOURCETYPE='DATE' THEN 91      WHEN D.SOURCETYPE='TIME' THEN 92      WHEN D.SOURCETYPE='TIMESTAMP' THEN 93      WHEN D.SOURCETYPE='DATALINK' THEN -400      WHEN D.SOURCETYPE='XML' THEN -370      ELSE 0    END ),    CAST( NULL AS VARCHAR(8) ),    SMALLINT( 1 )    FROM      SYSIBM.SYSCOLUMNS C,      SYSIBM.SYSDATATYPES D,      SYSIBM.SYSCOLPROPERTIES P,      SYSIBM.SYSTABLES T,      TYPEINTS I,      TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B    WHERE      C.COLTYPE = 'REF'      AND I.TYPEINT = 22      AND P.COLNAME = C.NAME      AND P.TABSCHEMA = C.TBCREATOR      AND P.TABNAME = C.TBNAME      AND P.TARGET_TYPENAME = D.NAME      AND P.TARGET_TYPESCHEMA = D.SCHEMA      AND T.TYPE = 'A'      AND B.BASESCHEMA = C.TBCREATOR      AND B.BASENAME = C.TBNAME      AND C.COLTYPE = I.COLTYPE;

CREATE VIEW "SYSIBM"."SQLFOREIGNKEYS" ("PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY", "UNIQUE_OR_PRIMARY") AS
SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(T1.CREATOR),     T1.NAME,     PK.COLNAME,     CAST( NULL AS VARCHAR(128) ),     RTRIM(T2.CREATOR),     T2.NAME,     FK.COLNAME,     PK.COLSEQ,     SMALLINT(       CASE R.UPDATERULE         WHEN 'C' THEN 0         WHEN 'R' THEN 1         WHEN 'N' THEN 2         WHEN 'A' THEN 3       END), SMALLINT(       CASE R.DELETERULE         WHEN 'C' THEN 0         WHEN 'R' THEN 1         WHEN 'N' THEN 2         WHEN 'A' THEN 3       END),     FK.CONSTNAME,     PK.CONSTNAME,     SMALLINT(7),     CASE TC.CONSTRAINTYP         WHEN 'P' THEN CAST( 'PRIMARY' AS CHAR(7) )         WHEN 'U' THEN CAST( 'UNIQUE' AS CHAR(7) )     END   FROM     SYSIBM.SYSTABLES T1,     SYSIBM.SYSTABLES T2,     SYSIBM.SYSRELS R,     SYSIBM.SYSKEYCOLUSE PK,     SYSIBM.SYSKEYCOLUSE FK,     SYSIBM.SYSTABCONST TC,     TABLE(SYSPROC.BASE_TABLE(T1.CREATOR, T1.NAME)) AS B1,     TABLE(SYSPROC.BASE_TABLE(T2.CREATOR, T2.NAME)) AS B2   WHERE     PK.COLSEQ        = FK.COLSEQ     AND PK.TBNAME    = R.REFTBNAME     AND PK.TBCREATOR = R.REFTBCREATOR     AND FK.TBNAME    = R.TBNAME      AND FK.TBCREATOR = R.CREATOR     AND PK.CONSTNAME = R.REFKEYNAME     AND FK.CONSTNAME = R.RELNAME     AND TC.NAME = R.REFKEYNAME     AND TC.TBNAME    = PK.TBNAME     AND TC.TBCREATOR = PK.TBCREATOR     AND B1.BASESCHEMA = R.REFTBCREATOR     AND B1.BASENAME   = R.REFTBNAME     AND B2.BASESCHEMA = R.CREATOR     AND B2.BASENAME   = R.TBNAME     AND T1.TYPE IN ('A', 'T')     AND T2.TYPE IN ('A', 'T');

CREATE VIEW "SYSIBM"."SQLPRIMARYKEYS" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", "PK_NAME") AS
SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(C.TBCREATOR),     C.TBNAME,     C.NAME,     C.KEYSEQ,     T.NAME   FROM     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABCONST T   WHERE     C.KEYSEQ > 0     AND T.CONSTRAINTYP = 'P'     AND T.TBCREATOR = C.TBCREATOR     AND T.TBNAME = C.TBNAME UNION   SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(C.TBCREATOR),     T.NAME,     C.NAME,     C.KEYSEQ,     TC.NAME   FROM     SYSIBM.SYSCOLUMNS C,     SYSIBM.SYSTABLES  T,     SYSIBM.SYSTABCONST TC,     TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B   WHERE     C.KEYSEQ > 0     AND T.TYPE = 'A'     AND B.BASESCHEMA = C.TBCREATOR     AND B.BASENAME = C.TBNAME     AND TC.CONSTRAINTYP = 'P'     AND TC.TBCREATOR = C.TBCREATOR     AND TC.TBNAME = C.TBNAME;

CREATE VIEW "SYSIBM"."SQLPROCEDURECOLS" ("PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "COLUMN_NAME", "COLUMN_TYPE", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE", "JDBC_DATA_TYPE") AS
SELECT CAST( NULL AS VARCHAR(128) ),  RTRIM(PARM.ROUTINESCHEMA),  PARM.ROUTINENAME,  PARM.PARMNAME,  SMALLINT( CASE      WHEN ROWTYPE = 'P' THEN 1      WHEN ROWTYPE = 'O' THEN 4      WHEN ROWTYPE = 'B' THEN 2      ELSE 0  END), SMALLINT( CASE     WHEN TYPENAME='INTEGER' THEN 4     WHEN TYPENAME='SMALLINT' THEN 5     WHEN TYPENAME='BIGINT' THEN -5     WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 7     WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 8     WHEN TYPENAME='REAL' THEN 7     WHEN TYPENAME='DOUBLE' THEN 8     WHEN TYPENAME='CHARACTER' AND PARM.CODEPAGE <> 0 then 1     WHEN TYPENAME='CHARACTER' AND PARM.CODEPAGE = 0 then -2     WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE <> 0 THEN 12     WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE = 0 THEN -3     WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE <> 0 THEN -1     WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE = 0 THEN -4     WHEN TYPENAME='DECIMAL' THEN 3     WHEN TYPENAME='GRAPHIC' THEN -95     WHEN TYPENAME='VARG' THEN -96     WHEN TYPENAME='LONGVARG' THEN -97     WHEN TYPENAME='BLOB' THEN -98     WHEN TYPENAME='CLOB' THEN -99     WHEN TYPENAME='DBCLOB' THEN -350     WHEN TYPENAME='DATE' THEN 91     WHEN TYPENAME='TIME' THEN 92     WHEN TYPENAME='TIMESTAMP' THEN 93     WHEN TYPENAME='DATALINK' THEN -400     WHEN TYPENAME='XML' THEN -370     ELSE 0 END),  CAST( CASE     WHEN TYPENAME='INTEGER' THEN 'INTEGER'     WHEN TYPENAME='SMALLINT' THEN 'SMALLINT'     WHEN TYPENAME='BIGINT' THEN 'BIGINT'     WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 'REAL'     WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 'DOUBLE'     WHEN TYPENAME='REAL' THEN 'REAL'     WHEN TYPENAME='DOUBLE' THEN 'DOUBLE'     WHEN TYPENAME='CHARACTER' AND PARM.CODEPAGE <> 0 THEN 'CHAR'     WHEN TYPENAME='CHARACTER' AND PARM.CODEPAGE = 0 THEN 'CHAR () FOR BIT DATA'     WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE <> 0 THEN 'VARCHAR'     WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE = 0 THEN 'VARCHAR () FOR BIT DATA'     WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE <> 0 THEN 'LONG VARCHAR'     WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE = 0 THEN 'LONG VARCHAR FOR BIT DATA'     WHEN TYPENAME='DECIMAL' THEN 'DECIMAL'     WHEN TYPENAME='GRAPHIC' THEN 'GRAPHIC'     WHEN TYPENAME='VARG' THEN 'VARGRAPHIC'     WHEN TYPENAME='LONGVARG' THEN 'LONG VARGRAPHIC'     WHEN TYPENAME='BLOB' THEN 'BLOB'     WHEN TYPENAME='CLOB' THEN 'CLOB'     WHEN TYPENAME='DBCLOB' THEN 'DBCLOB'     WHEN TYPENAME='DATE' THEN 'DATE'     WHEN TYPENAME='TIME' THEN 'TIME'     WHEN TYPENAME='TIMESTAMP' THEN 'TIMESTAMP'     WHEN TYPENAME='DATALINK' THEN 'DATALINK'     WHEN TYPENAME='XML' THEN 'XML'     ELSE TYPENAME END AS VARCHAR(261) ),  CASE     WHEN TYPENAME='INTEGER' THEN 10     WHEN TYPENAME='SMALLINT' THEN 5     WHEN TYPENAME='BIGINT' THEN 19     WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 7     WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 15     WHEN TYPENAME='REAL' THEN 7     WHEN TYPENAME='DOUBLE' THEN 15     WHEN TYPENAME='CHARACTER' THEN LENGTH     WHEN TYPENAME='VARCHAR' THEN LENGTH     WHEN TYPENAME='LONGVAR' THEN LENGTH     WHEN TYPENAME='DECIMAL' THEN LENGTH     WHEN TYPENAME='GRAPHIC' THEN LENGTH     WHEN TYPENAME='VARG' THEN LENGTH     WHEN TYPENAME='LONGVARG' THEN LENGTH     WHEN TYPENAME='BLOB' THEN LENGTH     WHEN TYPENAME='CLOB' THEN LENGTH     WHEN TYPENAME='DBCLOB' THEN LENGTH     WHEN TYPENAME='DATE' THEN 10     WHEN TYPENAME='TIME' THEN 8     WHEN TYPENAME='TIMESTAMP' THEN       CASE WHEN SCALE=0 THEN 19            ELSE 20+SCALE       END     WHEN TYPENAME='XML' THEN LENGTH     ELSE LENGTH END, CASE     WHEN TYPENAME='INTEGER' THEN 4     WHEN TYPENAME='SMALLINT' THEN 2     WHEN TYPENAME='BIGINT' THEN 8     WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 4     WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 8     WHEN TYPENAME='REAL' THEN 4     WHEN TYPENAME='DOUBLE' THEN 8     WHEN TYPENAME='CHARACTER' THEN LENGTH     WHEN TYPENAME='VARCHAR' THEN LENGTH     WHEN TYPENAME='LONGVAR' THEN LENGTH     WHEN TYPENAME='DECIMAL' THEN LENGTH + 2     WHEN TYPENAME='GRAPHIC' THEN LENGTH * 2     WHEN TYPENAME='VARG' THEN LENGTH * 2     WHEN TYPENAME='LONGVARG' THEN LENGTH * 2     WHEN TYPENAME='BLOB' THEN LENGTH     WHEN TYPENAME='CLOB' THEN LENGTH     WHEN TYPENAME='DBCLOB' THEN LENGTH * 2     WHEN TYPENAME='DATE' THEN 6     WHEN TYPENAME='TIME' THEN 6     WHEN TYPENAME='TIMESTAMP' THEN 16     WHEN TYPENAME='XML' THEN LENGTH     ELSE LENGTH END, CAST( CASE     WHEN TYPENAME='DECIMAL' THEN SCALE     WHEN TYPENAME='INTEGER' THEN 0     WHEN TYPENAME='SMALLINT' THEN 0     WHEN TYPENAME='BIGINT' THEN 0     WHEN TYPENAME='TIMESTAMP' THEN SCALE     ELSE NULL END AS SMALLINT ),    CAST( CASE     WHEN TYPENAME='DECIMAL' THEN 10     WHEN TYPENAME='INTEGER' THEN 10     WHEN TYPENAME='SMALLINT' THEN 10     WHEN TYPENAME='BIGINT' THEN 10     WHEN TYPENAME='REAL' THEN 10     WHEN TYPENAME='FLOAT' THEN 10     WHEN TYPENAME='DOUBLE' THEN 10     ELSE NULL END AS SMALLINT ), 1, PROC.REMARKS, CAST( NULL AS VARCHAR(254) ), SMALLINT(CASE     WHEN TYPENAME='INTEGER' THEN 4     WHEN TYPENAME='SMALLINT' THEN 5     WHEN TYPENAME='BIGINT' THEN -5     WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 7     WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 8     WHEN TYPENAME='REAL' THEN 7     WHEN TYPENAME='DOUBLE' THEN 8     WHEN TYPENAME='CHARACTER' THEN 1     WHEN TYPENAME='VARCHAR' THEN 12     WHEN TYPENAME='LONGVAR' THEN -1     WHEN TYPENAME='DECIMAL' THEN 3     WHEN TYPENAME='GRAPHIC' THEN -95     WHEN TYPENAME='VARG' THEN -96     WHEN TYPENAME='LONGVARG' THEN -97     WHEN TYPENAME='BLOB' THEN -98     WHEN TYPENAME='CLOB' THEN -99     WHEN TYPENAME='DBCLOB' THEN -350     WHEN TYPENAME='DATE' THEN 9     WHEN TYPENAME='TIME' THEN 9     WHEN TYPENAME='TIMESTAMP' THEN 9     WHEN TYPENAME='XML' THEN -370     ELSE 0 END),  SMALLINT( CASE     WHEN TYPENAME='DATE' THEN 1     WHEN TYPENAME='TIME' THEN 2     WHEN TYPENAME='TIMESTAMP' THEN 3     ELSE NULL END), CASE     WHEN TYPENAME='CHARACTER' THEN LENGTH     WHEN TYPENAME='VARCHAR' THEN LENGTH     WHEN TYPENAME='LONGVAR' THEN LENGTH     WHEN TYPENAME='GRAPHIC' THEN LENGTH * 2     WHEN TYPENAME='VARG' THEN LENGTH * 2     WHEN TYPENAME='LONGVARG' THEN LENGTH * 2     WHEN TYPENAME='BLOB' THEN LENGTH     WHEN TYPENAME='CLOB' THEN LENGTH     WHEN TYPENAME='DBCLOB' THEN LENGTH * 2     WHEN TYPENAME='XML' THEN LENGTH     ELSE NULL END, CAST( ORDINAL AS INTEGER ), 'YES',  SMALLINT( CASE   WHEN TYPENAME='INTEGER' THEN 4   WHEN TYPENAME='SMALLINT' THEN 5   WHEN TYPENAME='BIGINT' THEN -5   WHEN TYPENAME='FLOAT' AND LENGTH=4 THEN 7    WHEN TYPENAME='FLOAT' AND LENGTH=8 THEN 8   WHEN TYPENAME='REAL' THEN 7   WHEN TYPENAME='DOUBLE' THEN 8   WHEN TYPENAME='CHAR' AND PARM.CODEPAGE <> 0 then 1   WHEN TYPENAME='CHAR' AND PARM.CODEPAGE = 0 then -2   WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE <> 0 THEN 12   WHEN TYPENAME='VARCHAR' AND PARM.CODEPAGE = 0 THEN -3   WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE <> 0 THEN -1   WHEN TYPENAME='LONGVAR' AND PARM.CODEPAGE = 0 THEN -4   WHEN TYPENAME='DECIMAL' THEN 3   WHEN TYPENAME='GRAPHIC' THEN 1   WHEN TYPENAME='VARG' THEN 12   WHEN TYPENAME='LONGVARG' THEN -1   WHEN TYPENAME='BLOB' THEN 2004   WHEN TYPENAME='CLOB' THEN 2005   WHEN TYPENAME='DBCLOB' THEN 2005   WHEN TYPENAME='DATE' THEN 91   WHEN TYPENAME='TIME' THEN 92   WHEN TYPENAME='TIMESTAMP' THEN 93   WHEN TYPENAME='XML' THEN 1111   ELSE 0 END) FROM     SYSIBM.SYSROUTINEPARMS PARM, SYSIBM.SYSROUTINES PROC WHERE     PROC.ROUTINETYPE = 'P'     AND PARM.ROUTINETYPE = 'P'     AND PARM.ROUTINESCHEMA = PROC.ROUTINESCHEMA     AND PARM.ROUTINENAME = PROC.ROUTINENAME;

CREATE VIEW "SYSIBM"."SQLPROCEDURES" ("PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "NUM_INPUT_PARAMS", "NUM_OUTPUT_PARAMS", "NUM_RESULT_SETS", "REMARKS", "PROCEDURE_TYPE", "NUM_INOUT_PARAMS") AS
WITH  IN ( ROUTINESCHEMA, ROUTINENAME, INCOUNT )   AS ( SELECT ROUTINESCHEMA, ROUTINENAME, COUNT(*)          FROM SYSIBM.SYSROUTINEPARMS          WHERE ROUTINETYPE = 'P'            AND ROWTYPE = 'P'          GROUP BY ROUTINESCHEMA, ROUTINENAME        UNION ALL        SELECT ROUTINESCHEMA, ROUTINENAME, 0          FROM SYSIBM.SYSROUTINES          WHERE ROUTINETYPE = 'P'            AND (ROUTINESCHEMA, ROUTINENAME)            NOT IN ( SELECT ROUTINESCHEMA, ROUTINENAME                     FROM SYSIBM.SYSROUTINEPARMS                     WHERE ROUTINETYPE = 'P'                       AND ROWTYPE = 'P' ) ),  OUT ( ROUTINESCHEMA, ROUTINENAME, OUTCOUNT )   AS ( SELECT ROUTINESCHEMA, ROUTINENAME, COUNT(*)          FROM SYSIBM.SYSROUTINEPARMS          WHERE ROUTINETYPE = 'P'            AND ROWTYPE = 'O'          GROUP BY ROUTINESCHEMA, ROUTINENAME        UNION ALL        SELECT ROUTINESCHEMA, ROUTINENAME, 0          FROM SYSIBM.SYSROUTINES          WHERE ROUTINETYPE = 'P'            AND (ROUTINESCHEMA, ROUTINENAME)            NOT IN ( SELECT ROUTINESCHEMA, ROUTINENAME                     FROM SYSIBM.SYSROUTINEPARMS                     WHERE ROUTINETYPE = 'P'                       AND ROWTYPE = 'O' ) ),  INOUT ( ROUTINESCHEMA, ROUTINENAME, INOUTCOUNT )   AS ( SELECT ROUTINESCHEMA, ROUTINENAME, COUNT(*)          FROM SYSIBM.SYSROUTINEPARMS          WHERE ROUTINETYPE = 'P'            AND ROWTYPE = 'B'          GROUP BY ROUTINESCHEMA, ROUTINENAME        UNION ALL        SELECT ROUTINESCHEMA, ROUTINENAME, 0          FROM SYSIBM.SYSROUTINES          WHERE ROUTINETYPE = 'P'            AND (ROUTINESCHEMA, ROUTINENAME)            NOT IN ( SELECT ROUTINESCHEMA, ROUTINENAME                     FROM SYSIBM.SYSROUTINEPARMS                     WHERE ROUTINETYPE = 'P'                       AND ROWTYPE = 'B' ) )   SELECT DISTINCT    CAST( NULL AS VARCHAR(128) ),     RTRIM(P.ROUTINESCHEMA),     P.ROUTINENAME,     I.INCOUNT,     O.OUTCOUNT,     P.RESULT_SETS,     P.REMARKS,     SMALLINT(1),     IO.INOUTCOUNT   FROM     SYSIBM.SYSROUTINES P,     IN I,     OUT O,     INOUT IO   WHERE P.ROUTINETYPE = 'P'     AND P.ROUTINESCHEMA = I.ROUTINESCHEMA     AND P.ROUTINENAME   = I.ROUTINENAME     AND P.ROUTINESCHEMA = O.ROUTINESCHEMA     AND P.ROUTINENAME   = O.ROUTINENAME     AND P.ROUTINESCHEMA = IO.ROUTINESCHEMA     AND P.ROUTINENAME   = IO.ROUTINENAME;

CREATE VIEW "SYSIBM"."SQLSCHEMAS" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "SELF_REF_COL_NAME", "REF_GENERATION", "DBNAME") AS
SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(NAME),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(254) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSSCHEMATA;

CREATE VIEW "SYSIBM"."SQLSPECIALCOLUMNS" ("SCOPE", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "PSEUDO_COLUMN", "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NULLABLE", "JDBC_DATA_TYPE") AS
WITH IDTABLES ( A, B )  AS ( SELECT TBCREATOR AS A, TBNAME AS B   FROM SYSIBM.SYSCOLUMNS   WHERE IDENTITY = 'Y' ), SUBINDEXES ( NAME, CREATOR, TBNAME, TBCREATOR, UNIQUERULE, COLCOUNT, IID )  AS (   SELECT I.NAME, I.CREATOR, I.TBNAME, I.TBCREATOR,    I.UNIQUERULE, I.COLCOUNT, I.IID    FROM SYSIBM.SYSINDEXES I    WHERE I.UNIQUERULE IN ( 'P', 'U' )     AND (I.TBCREATOR, I.TBNAME)      NOT IN (SELECT A, B FROM IDTABLES) ), OPTIMALINDEXES ( NAME, CREATOR ) AS (   SELECT NAME AS A, CREATOR AS B     FROM SUBINDEXES I     WHERE I.UNIQUERULE = 'P'   UNION ALL   SELECT NAME AS A, CREATOR AS B    FROM SUBINDEXES    WHERE UNIQUERULE = 'U'    AND (TBCREATOR, TBNAME) NOT IN (     SELECT TBCREATOR, TBNAME     FROM SUBINDEXES WHERE UNIQUERULE = 'P' )    AND ( TBNAME, TBCREATOR, IID)     IN ( SELECT TBNAME, TBCREATOR, MIN(IID)      FROM SUBINDEXES      WHERE (TBNAME, TBCREATOR, COLCOUNT)      IN ( SELECT TBNAME, TBCREATOR, MIN(COLCOUNT)       FROM SUBINDEXES       GROUP BY TBNAME, TBCREATOR )      GROUP BY TBNAME, TBCREATOR ) )   SELECT    SMALLINT(0),    Q.COLUMN_NAME,    Q.DATA_TYPE,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(Q.TABLE_SCHEM),    Q.TABLE_NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE  FROM    OPTIMALINDEXES O,    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U,    SYSIBM.SQLCOLUMNS Q  WHERE    I.NAME = O.NAME    AND I.CREATOR = O.CREATOR    AND Q.DATA_TYPE <> 20    AND Q.TABLE_SCHEM = I.TBCREATOR    AND Q.TABLE_NAME = I.TBNAME    AND I.CREATOR = U.INDSCHEMA    AND I.NAME = U.INDNAME    AND Q.COLUMN_NAME = U.COLNAME UNION ALL SELECT    SMALLINT(0),    Q.COLUMN_NAME,    20,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(Q.TABLE_SCHEM),    Q.TABLE_NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE   FROM    OPTIMALINDEXES O,    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U,    SYSIBM.SQLCOLUMNS Q   WHERE     I.NAME = O.NAME    AND I.CREATOR = O.CREATOR    AND Q.DATA_TYPE = 20    AND Q.TABLE_SCHEM = I.TBCREATOR    AND Q.TABLE_NAME = I.TBNAME    AND I.CREATOR = U.INDSCHEMA    AND I.NAME = U.INDNAME    AND Q.COLUMN_NAME = U.COLNAME UNION ALL  SELECT    SMALLINT(0),    Q.COLUMN_NAME,    Q.DATA_TYPE,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(Q.TABLE_SCHEM),    Q.TABLE_NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE  FROM     SYSIBM.SYSCOLUMNS C,    SYSIBM.SQLCOLUMNS Q  WHERE    C.TBCREATOR = Q.TABLE_SCHEM    AND C.TBNAME = Q.TABLE_NAME    AND C.NAME = Q.COLUMN_NAME    AND C.IDENTITY = 'Y' UNION ALL SELECT    SMALLINT(0),    Q.COLUMN_NAME,    Q.DATA_TYPE,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE   FROM    OPTIMALINDEXES O,    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U,    SYSIBM.SYSTABLES T,    SYSIBM.SQLCOLUMNS Q,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE    I.NAME = O.NAME    AND I.CREATOR = O.CREATOR    AND Q.DATA_TYPE <> 20    AND Q.TABLE_SCHEM = I.TBCREATOR    AND Q.TABLE_NAME = I.TBNAME    AND I.CREATOR = U.INDSCHEMA    AND I.NAME = U.INDNAME    AND Q.COLUMN_NAME = U.COLNAME    AND T.TYPE = 'A'    AND B.BASESCHEMA = Q.TABLE_SCHEM    AND B.BASENAME = Q.TABLE_NAME  UNION ALL SELECT    SMALLINT(0),    Q.COLUMN_NAME,    20,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE FROM    OPTIMALINDEXES O,    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U,    SYSIBM.SYSTABLES T,    SYSIBM.SQLCOLUMNS Q,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE    I.NAME = O.NAME    AND I.CREATOR = O.CREATOR    AND Q.DATA_TYPE = 20     AND Q.TABLE_SCHEM = I.TBCREATOR    AND Q.TABLE_NAME = I.TBNAME    AND I.CREATOR = U.INDSCHEMA    AND I.NAME = U.INDNAME    AND Q.COLUMN_NAME = U.COLNAME    AND T.TYPE = 'A'    AND B.BASESCHEMA = Q.TABLE_SCHEM    AND B.BASENAME = Q.TABLE_NAME UNION ALL  SELECT    SMALLINT(0),    C.NAME,    Q.DATA_TYPE,    Q.TYPE_NAME,    Q.COLUMN_SIZE,    Q.BUFFER_LENGTH,    Q.DECIMAL_DIGITS,    Q.PSEUDO_COLUMN,    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    Q.NULLABLE,    Q.JDBC_DATA_TYPE  FROM    SYSIBM.SYSCOLUMNS C,    SYSIBM.SQLCOLUMNS Q,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE    C.TBCREATOR = Q.TABLE_SCHEM    AND C.TBNAME = Q.TABLE_NAME    AND C.NAME = Q.COLUMN_NAME    AND C.IDENTITY = 'Y'     AND T.TYPE = 'A'    AND B.BASESCHEMA = C.TBCREATOR    AND B.BASENAME = C.TBNAME;

CREATE VIEW "SYSIBM"."SQLSTATISTICS" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION") AS
SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(I.TBCREATOR),    I.TBNAME,    SMALLINT( CASE     WHEN I.UNIQUERULE='D' THEN 1     WHEN I.UNIQUERULE='P' THEN 0     WHEN I.UNIQUERULE='U' THEN 0     ELSE 0    END),    RTRIM(I.CREATOR),    I.NAME,    SMALLINT(CASE     WHEN I.INDEXTYPE='CLUS' THEN 1     WHEN I.INDEXTYPE='REG'  THEN 3     ELSE 3    END),    SMALLINT(U.COLSEQ),    U.COLNAME,    U.COLORDER,    CASE WHEN I.FULLKEYCARD=-1 THEN NULL ELSE I.FULLKEYCARD END,    INTEGER(CASE WHEN I.NLEAF=-1 THEN NULL            WHEN I.NLEAF > 2147483647 THEN 2147483647            ELSE I.NLEAF END),    CAST( NULL AS VARCHAR(128) )  FROM    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U  WHERE    U.INDSCHEMA = I.CREATOR    AND U.INDNAME = I.NAME    AND I.INDEXTYPE <> 'XRGN'     AND I.INDEXTYPE <> 'XPTH'     AND I.INDEXTYPE <> 'XVIP'   UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(CREATOR),    NAME,    CAST( NULL AS SMALLINT ),    CAST( NULL AS VARCHAR(128) ),    CAST( NULL AS VARCHAR(128) ),    CAST( 0 AS SMALLINT ),    CAST( NULL AS SMALLINT ),     CAST( NULL AS VARCHAR(128) ),    CAST( NULL AS CHAR(1) ),    CASE WHEN CARD=-1 THEN NULL ELSE CARD END,    INTEGER(CASE      WHEN NPAGES=-1 THEN NULL      WHEN NPAGES=-2 THEN NULL      WHEN NPAGES > 2147483647 THEN 2147483647      ELSE NPAGES    END),    CAST( NULL AS VARCHAR(128) )  FROM    SYSIBM.SYSTABLES UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    SMALLINT( CASE     WHEN I.UNIQUERULE='D' THEN 1     WHEN I.UNIQUERULE='P' THEN 0     WHEN I.UNIQUERULE='U' THEN 0     ELSE 0    END),    RTRIM(I.CREATOR),    I.NAME,    SMALLINT( CASE     WHEN I.INDEXTYPE='CLUS' THEN 1     WHEN I.INDEXTYPE='REG'  THEN 3     ELSE 3    END),    SMALLINT(U.COLSEQ),    U.COLNAME,    U.COLORDER,    CASE WHEN I.FULLKEYCARD=-1 THEN NULL ELSE I.FULLKEYCARD END,    INTEGER(CASE WHEN I.NLEAF=-1 THEN NULL            WHEN I.NLEAF > 2147483647 THEN 2147483647            ELSE I.NLEAF END),    CAST( NULL AS VARCHAR(128) )  FROM    SYSIBM.SYSINDEXES I,    SYSIBM.SYSINDEXCOLUSE U,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE    U.INDSCHEMA = I.CREATOR    AND U.INDNAME = I.NAME    AND T.TYPE = 'A'    AND I.INDEXTYPE <> 'XRGN'     AND I.INDEXTYPE <> 'XPTH'     AND I.INDEXTYPE <> 'XVIP'     AND B.BASESCHEMA = I.TBCREATOR    AND B.BASENAME = I.TBNAME;

CREATE VIEW "SYSIBM"."SQLTABLEPRIVILEGES" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", "IS_GRANTABLE", "DBNAME") AS
SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'ALTER',    CASE      WHEN ALTERAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    ALTERAUTH IN ('Y', 'G')  UNION SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'DELETE',    CASE      WHEN DELETEAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    DELETEAUTH IN ('Y', 'G')  UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'CONTROL',    'NO',    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    CONTROLAUTH='Y'  UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'INDEX',    CASE      WHEN INDEXAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    INDEXAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'INSERT',    CASE      WHEN INSERTAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    INSERTAUTH IN ('Y', 'G')  UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'REFERENCES',    CASE      WHEN REFAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    REFAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'SELECT',    CASE      WHEN SELECTAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE    SELECTAUTH IN ('Y', 'G')  UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(TCREATOR),    TTNAME,    RTRIM(GRANTOR),    RTRIM(GRANTEE),    'UPDATE',    CASE      WHEN UPDATEAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH  WHERE      UPDATEAUTH IN ('Y', 'G') UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'ALTER',    CASE      WHEN A.ALTERAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.ALTERAUTH IN ('Y', 'G')      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'CONTROL',    'NO',    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.CONTROLAUTH='Y'      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'DELETE',    CASE      WHEN A.DELETEAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.DELETEAUTH IN ('Y','G')      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'INDEX',    CASE      WHEN A.INDEXAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.INDEXAUTH IN ('Y', 'G')      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'INSERT',    CASE      WHEN A.INSERTAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.INSERTAUTH IN ('Y', 'G')   AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'REFERENCES',    CASE      WHEN A.REFAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.REFAUTH IN ('Y', 'G')    AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'SELECT',    CASE      WHEN A.SELECTAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.SELECTAUTH IN ('Y', 'G')      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME UNION  SELECT    CAST( NULL AS VARCHAR(128) ),    RTRIM(T.CREATOR),    T.NAME,    RTRIM(A.GRANTOR),    RTRIM(A.GRANTEE),    'UPDATE',    CASE      WHEN A.UPDATEAUTH='G' THEN 'YES' ELSE 'NO'    END,    CAST( NULL AS VARCHAR(8) )  FROM    SYSIBM.SYSTABAUTH A,    SYSIBM.SYSTABLES T,    TABLE(SYSPROC.BASE_TABLE(T.CREATOR, T.NAME)) AS B  WHERE      A.UPDATEAUTH IN ('Y', 'G')      AND T.TYPE = 'A'      AND B.BASESCHEMA = A.TCREATOR      AND B.BASENAME = A.TTNAME;

CREATE VIEW "SYSIBM"."SQLTABLETYPES" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "SELF_REF_COL_NAME", "REF_GENERATION", "DBNAME", "TYPE") AS
VALUES     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'ALIAS', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'A', 1 ) ),  ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'HIERARCHY TABLE', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'H', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'INOPERATIVE VIEW', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( '?', 1 ) ),  ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'NICKNAME', 128 ),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'N', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'MATERIALIZED QUERY TABLE', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'S', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'SYSTEM TABLE', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( '?', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'TABLE', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'T', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'TYPED TABLE', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'U', 1 ) ),  ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'TYPED VIEW', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'W', 1 ) ),     ( CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       VARCHAR( 'VIEW', 128),       CAST( NULL AS VARCHAR(254) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(128) ),       CAST( NULL AS VARCHAR(8) ),       CHAR( 'V', 1 ) );

CREATE VIEW "SYSIBM"."SQLTABLES" ("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "SELF_REF_COL_NAME", "REF_GENERATION", "DBNAME") AS
SELECT     CAST( NULL AS VARCHAR(128) ),     RTRIM(T.CREATOR),     T.NAME,     CASE       WHEN T.TYPE='T' AND T.CREATOR='SYSIBM' THEN 'SYSTEM TABLE'       WHEN T.TYPE='T' AND T.CREATOR<>'SYSIBM' THEN 'TABLE'       WHEN T.TYPE='V' AND T.STATUS<>'X' THEN 'VIEW'       WHEN T.TYPE='V' AND T.STATUS='X' THEN 'INOPERATIVE VIEW'       WHEN T.TYPE='X' THEN NULL       ELSE TT.TABLE_TYPE     END,     T.REMARKS,     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(128) ),     CAST( NULL AS VARCHAR(8) )   FROM     SYSIBM.SYSTABLES T,     SYSIBM.SQLTABLETYPES TT   WHERE     T.TYPE = TT.TYPE;

CREATE VIEW "SYSIBM"."SQLTYPEINFO" ("TYPE_NAME", "DATA_TYPE", "COLUMN_SIZE", "LITERAL_PREFIX", "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", "AUTO_UNIQUE_VALUE", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "NUM_PREC_RADIX", "INTERVAL_PRECISION", "JDBC_DATA_TYPE") AS
VALUES   ( VARCHAR( 'INTEGER', 128 ),     SMALLINT(4),     10,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(1),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(0),     4,     CAST(NULL AS INTEGER),     10,     CAST(NULL AS SMALLINT),     SMALLINT(4) ),   ( 'SMALLINT',     SMALLINT(5),     5,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(1),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(0),     5,     CAST(NULL AS INTEGER),     10,     CAST(NULL AS SMALLINT),     SMALLINT(5) ),   ( 'BIGINT',     SMALLINT(-5),     20,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(1),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(0),     -5,     CAST(NULL AS INTEGER),     10,     CAST(NULL AS SMALLINT),     SMALLINT(-5) ),   ( 'REAL',     SMALLINT(7),     24,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(0),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(0),     7,     CAST(NULL AS INTEGER),     2,     CAST(NULL AS SMALLINT),     SMALLINT(7) ),   ( 'DOUBLE',     SMALLINT(8),     53,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(0),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(0),     8,     CAST(NULL AS INTEGER),     2,     CAST(NULL AS SMALLINT),     SMALLINT(8) ),   ( 'CHAR',     SMALLINT(1),     254,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     1,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(1) ),   ( 'VARCHAR',     SMALLINT(12),     4000,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     12,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(12) ),   ( 'LONG VARCHAR',     SMALLINT(-1),     32700,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(1),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -1,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(-1) ),   ( 'DECIMAL',     SMALLINT(3),     31,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST('PRECISION,SCALE' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     SMALLINT(0),     SMALLINT(0),     SMALLINT(0),     CAST(NULL AS VARCHAR(128)),     SMALLINT(0),     SMALLINT(31),     3,     CAST(NULL AS INTEGER),     10,     CAST(NULL AS SMALLINT),     SMALLINT(3) ),   ( 'GRAPHIC',     SMALLINT(-95),     127,     CAST('G''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -95,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(1) ),   ( 'VARGRAPHIC',     SMALLINT(-96),     16336,     CAST('G''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -96,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(12) ),   ( 'LONG VARGRAPHIC',     SMALLINT(-97),     16350,     CAST('G''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(1),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -97,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(-1) ),   ( 'BLOB',     SMALLINT(-98),     2147483647,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(1),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -98,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(2004) ),   ( 'CLOB',     SMALLINT(-99),     2147483647,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(1),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -99,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(2005) ),   ( 'DBCLOB',     SMALLINT(-350),     1073741823,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(1),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -350,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(2005) ),   ( 'DATE',     SMALLINT(91),     10,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     9,     1,     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(91) ),   ( 'TIME',     SMALLINT(92),     8,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(0 AS SMALLINT),     CAST(0 AS SMALLINT),     9,     2,     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(92) ),   ( 'TIMESTAMP',     SMALLINT(93),     32,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(2),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(0 AS SMALLINT),     CAST(12 AS SMALLINT),     9,     3,     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(93) ),   ( 'DATALINK',     SMALLINT(-400),     254,     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(0),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -400,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(70) ),   ( 'LONG VARCHAR FOR BIT DATA',     SMALLINT(-4),     32700,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(0),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -4,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(-4) ),   ( 'VARCHAR () FOR BIT DATA',     SMALLINT(-3),     32762,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -3,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(-3) ),   ( 'CHAR () FOR BIT DATA',     SMALLINT(-2),     254,     CAST('''' AS VARCHAR(128)),     CAST('''' AS VARCHAR(128)),     CAST('LENGTH' AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(0),     SMALLINT(3),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -2,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(-2) ),   ( 'DISTINCT',     SMALLINT(2001),     CAST(NULL AS INTEGER),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(2001) ),   ( 'XML',     SMALLINT(-370),     CAST(NULL AS INTEGER),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS VARCHAR(128)),     SMALLINT(1),     SMALLINT(1),     SMALLINT(0),     CAST(NULL AS SMALLINT),     SMALLINT(0),     CAST(NULL AS SMALLINT),     CAST(NULL AS VARCHAR(128)),     CAST(NULL AS SMALLINT),     CAST(NULL AS SMALLINT),     -370,     CAST(NULL AS INTEGER),     CAST(NULL AS INTEGER),     CAST(NULL AS SMALLINT),     SMALLINT(1111) );

CREATE VIEW "SYSIBM"."SQLUDTS" ("TYPE_CAT", "TYPE_SCHEM", "TYPE_MODULE", "TYPE_NAME", "CLASS_NAME", "DATA_TYPE", "BASE_TYPE", "REMARKS") AS
SELECT      CAST( NULL AS VARCHAR(128) ),     RTRIM(schema),     (SELECT modulename FROM SYSIBM.SYSMODULES WHERE moduleid=typemoduleid),     name,     CAST( CASE      WHEN metatype in ('A','L') THEN 'java.sql.Array'      WHEN sourcetype='INTEGER' THEN 'java.lang.Integer'      WHEN sourcetype='SMALLINT' THEN 'java.lang.Short'      WHEN sourcetype='BIGINT' THEN 'java.lang.Long'      WHEN sourcetype='REAL' THEN 'java.lang.Float'      WHEN sourcetype='DOUBLE' THEN 'java.lang.Double'      WHEN sourcetype='DECFLOAT' THEN 'java.math.BigDecimal'      WHEN sourcetype='CHARACTER' AND b.CODEPAGE <> 0 THEN 'java.lang.String'      WHEN sourcetype='CHARACTER' AND b.CODEPAGE = 0  THEN 'byte[]'      WHEN sourcetype='VARCHAR' AND b.CODEPAGE <> 0 THEN 'java.lang.String'      WHEN sourcetype='VARCHAR' AND b.CODEPAGE = 0 THEN 'byte[]'      WHEN sourcetype='DECIMAL' THEN 'java.math.BigDecimal'      WHEN sourcetype='NUMERIC' THEN 'java.math.BigDecimal'      WHEN sourcetype='GRAPHIC' THEN 'java.lang.String'      WHEN sourcetype='VARGRAPHIC'  THEN 'java.lang.String'      WHEN sourcetype='BLOB' THEN 'java.sql.Blob'      WHEN sourcetype='CLOB' THEN 'java.sql.Clob'      WHEN sourcetype='DBCLOB' THEN 'java.sql.Clob'      WHEN sourcetype='DATE' THEN 'java.sql.Date'      WHEN sourcetype='TIME' THEN 'java.sql.Time'      WHEN sourcetype='TIMESTAMP' THEN 'java.sql.Timestamp'      WHEN sourcetype='ROWID'   THEN 'byte[]'      WHEN sourcetype='DATALINK' THEN 'java.net.URL'      WHEN sourcetype IS NULL and metatype='C' THEN 'java.sql.ResultSet'      ELSE ''    END AS VARCHAR(30)),     SMALLINT( CASE      WHEN metatype IN ('T','C') THEN 2001      WHEN metatype='R' THEN 2002      WHEN metatype='A' THEN 2003      WHEN metatype='L' THEN 1111    END),    SMALLINT(CASE       WHEN sourcetype='INTEGER'  THEN 4       WHEN sourcetype='SMALLINT' THEN 5      WHEN sourcetype='BIGINT' THEN -5      WHEN sourcetype='REAL' THEN 7      WHEN sourcetype='DOUBLE' THEN 8      WHEN sourcetype='DECFLOAT' THEN 1111      WHEN sourcetype='CHARACTER' AND b.CODEPAGE <> 0 THEN 1      WHEN sourcetype='CHARACTER' AND b.CODEPAGE = 0 THEN -2      WHEN sourcetype='VARCHAR' AND b.CODEPAGE <> 0 THEN 12      WHEN sourcetype='VARCHAR' AND b.CODEPAGE = 0 THEN -3      WHEN sourcetype='DECIMAL' THEN 3      WHEN sourcetype='NUMERIC' THEN 2      WHEN sourcetype='GRAPHIC' THEN 1      WHEN sourcetype='VARGRAPHIC' THEN 12      WHEN sourcetype='BLOB' THEN 2004      WHEN sourcetype='CLOB' THEN 2005      WHEN sourcetype='DBCLOB' THEN 2005      WHEN sourcetype='DATE' THEN 91      WHEN sourcetype='TIME' THEN 92      WHEN sourcetype='TIMESTAMP' THEN 93      WHEN sourcetype='ROWID' THEN 1111      WHEN sourcetype='DATALINK' THEN 70      WHEN sourcetype IS NULL AND metatype='C' THEN 1111      ELSE 0    END),    remarks   FROM     SYSIBM.SYSDATATYPES B   WHERE     metatype IN ('A','C','L','R','T');

CREATE VIEW "SYSIBM"."SYSDUMMY1" ("IBMREQD") AS
values (char('Y'));

CREATE VIEW "SYSIBM"."SYSFUNCPARMS" ("FNAME", "FSCHEMA", "FSPECIFIC", "ROWTYPE", "ORDINAL", "TYPENAME", "TYPESCHEMA", "LENGTH", "SCALE", "CODEPAGE", "CAST_FUNCTION_ID", "PARMNAME", "AS_LOCATOR", "TARGET_TYPESCHEMA", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME", "TRANSFORM_GRPNAME") AS
select 
routinename, routineschema, specificname, rowtype, ordinal, 
typename, typeschema, length, scale, codepage, cast_function_id, 
parmname, locator, target_typeschema, target_typename, 
scope_tabschema, scope_tabname, transform_grpname 
from sysibm.sysroutineparms 
where routinetype in ('F', 'M') 
and routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSIBM"."SYSFUNCTIONS" ("NAME", "SCHEMA", "DEFINER", "SPECIFIC", "PARM_SIGNATURE", "FUNCTION_ID", "RETURN_TYPE", "ORIGIN", "TYPE", "CREATE_TIME", "PARM_COUNT", "VARIANT", "SIDE_EFFECTS", "FENCED", "NULLCALL", "CAST_FUNCTION", "ASSIGN_FUNCTION", "SCRATCHPAD", "FINAL_CALL", "LANGUAGE", "IMPLEMENTATION", "SOURCE_SPECIFIC", "SOURCE_SCHEMA", "IOS_PER_INVOC", "INSTS_PER_INVOC", "IOS_PER_ARGBYTE", "INSTS_PER_ARGBYTE", "PERCENT_ARGBYTES", "INITIAL_IOS", "INITIAL_INSTS", "INTERNAL_PREC1", "INTERNAL_PREC2", "REMARKS", "INTERNAL_DESC", "PARALLELIZABLE", "CONTAINS_SQL", "DBINFO", "RESULT_COLS", "BODY", "CARDINALITY", "PARM_STYLE", "METHOD", "IMPLEMENTED", "EFFECT", "FUNC_PATH", "TYPE_PRESERVING", "WITH_FUNC_ACCESS", "SELECTIVITY", "OVERRIDDEN_FUNCID", "SUBJECT_TYPESCHEMA", "SUBJECT_TYPENAME", "QUALIFIER", "CLASS", "JAR_ID") AS
select 
a.routinename, a.routineschema, a.definer, a.specificname, 
a.parm_signature, a.routine_id, 
a.return_type, a.origin, a.function_type, a.createdts, a.parm_count, 
CAST 
(CASE a.deterministic 
WHEN 'Y' THEN 'N' 
WHEN 'N' THEN 'Y' 
ELSE ' ' END AS CHAR(1)), 
a.external_action, a.fenced, a.null_call, a.cast_function, 
a.assign_function, a.scratchpad, a.final_call, a.language, 
a.implementation, a.sourcespecific, a.sourceschema, a.ios_per_invoc, 
a.insts_per_invoc, a.ios_per_argbyte, a.insts_per_argbyte, 
a.percent_argbytes, a.initial_ios, a.initial_insts, a.internal_prec1, 
a.internal_prec2, a.remarks, a.internal_desc, a.parallel, 
a.sql_data_access, a.dbinfo, a.result_cols, a.text, a.cardinality, 
a.parameter_style, 
CAST 
(CASE a.routinetype 
WHEN 'M' THEN 'Y' ELSE 'N' END AS CHAR(1)), 
CASE 
WHEN a.routinetype = 'F' THEN 'Y' 
WHEN a.methodimplemented = 'N' AND a.with_func_access = 'N' THEN 'A' 
WHEN a.methodimplemented = 'Y' AND a.with_func_access = 'Y' THEN 'H' 
WHEN a.methodimplemented = 'Y' AND a.with_func_access = 'N' THEN 'M' 
ELSE ' ' 
END as methodimplemented, 
a.methodeffect, a.func_path, 
CAST 
(CASE 
WHEN a.type_preserving = 'Y' THEN 'Y' 
ELSE 'N' 
END AS CHAR(1)), 
CASE a.routinetype 
WHEN 'F' THEN 'Y' 
ELSE a.routinetype 
END as with_func_access, 
a.selectivity, a.overridden_methodid, 
a.subject_typeschema, a.subject_typename, a.qualifier, 
CASE 
WHEN a.language <> 'JAVA' THEN NULL 
ELSE 
(SELECT pj.class FROM 
SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id) 
END, 
CASE 
WHEN a.language <> 'JAVA' THEN NULL 
ELSE 
(SELECT pj.jar_id FROM 
SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id) 
END 
from sysibm.sysroutines as a 
where a.routinetype in ('F', 'M') 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSIBM"."SYSPROCEDURES" ("PROCSCHEMA", "PROCNAME", "SPECIFICNAME", "PROCEDURE_ID", "DEFINER", "PARM_COUNT", "PARM_SIGNATURE", "ORIGIN", "CREATE_TIME", "FENCED", "NULLCALL", "LANGUAGE", "IMPLEMENTATION", "PARM_STYLE", "RESULT_SETS", "REMARKS", "DETERMINISTIC", "PACKED_DESC", "CONTAINS_SQL", "DBINFO", "PROGRAM_TYPE", "VALID", "CLASS", "JAR_ID", "TEXT_BODY_OFFSET", "TEXT") AS
select 
a.routineschema, a.routinename, a.specificname, a.routine_id, a.definer, 
a.parm_count, a.parm_signature, a.origin, a.createdts, a.fenced, 
a.null_call, a.language, a.implementation, a.parameter_style, 
a.result_sets, a.remarks, a.deterministic, a.internal_desc, 
a.sql_data_access, a.dbinfo, a.program_type, a.valid, 
CASE 
WHEN a.language <> 'JAVA' THEN NULL 
ELSE 
(SELECT pj.class 
FROM SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id) 
END, 
CASE 
WHEN a.language <> 'JAVA' THEN NULL 
ELSE 
(SELECT pj.jar_id 
FROM SYSIBM.SYSROUTINEPROPERTIES AS pj 
WHERE pj.routine_id = a.routine_id) 
END, 
a.text_body_offset, a.text 
from sysibm.sysroutines as a 
where a.routinetype in ('P') 
and a.routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSIBM"."SYSPROCPARMS" ("PROCSCHEMA", "PROCNAME", "SPECIFICNAME", "ORDINAL", "PARMNAME", "TYPESCHEMA", "TYPENAME", "LENGTH", "SCALE", "CODEPAGE", "PARM_MODE", "AS_LOCATOR", "TARGET_TYPESCHEMA", "TARGET_TYPENAME", "SCOPE_TABSCHEMA", "SCOPE_TABNAME", "TYPEID", "SOURCETYPEID", "SERVERNAME", "DBCS_CODEPAGE", "NULLS") AS
select 
routineschema, routinename, specificname, ordinal, parmname, typeschema, 
typename, length, scale, codepage, 
CAST 
(CASE rowtype 
WHEN 'P' THEN 'IN' 
WHEN 'O' THEN 'OUT' 
ELSE 'INOUT' 
END AS VARCHAR(5)) , 
locator, target_typeschema, target_typename, scope_tabschema, 
scope_tabname, typeid, CAST(null as smallint),CAST(null as varchar(128)), 
CAST(null as smallint), CAST('Y' as char(1)) 
from sysibm.sysroutineparms 
where routinetype in ('P') 
and routineschema not in ('SYSIBMINTERNAL');

CREATE VIEW "SYSIBM"."SYSREVTYPEMAPPINGS" ("TYPE_MAPPING", "TYPESCHEMA", "TYPENAME", "TYPEID", "SOURCETYPEID", "DEFINER", "LOWER_LEN", "UPPER_LEN", "LOWER_SCALE", "UPPER_SCALE", "S_OPR_P", "BIT_DATA", "WRAPNAME", "SERVERNAME", "SERVERTYPE", "SERVERVERSION", "REMOTE_TYPESCHEMA", "REMOTE_TYPENAME", "REMOTE_META_TYPE", "REMOTE_LENGTH", "REMOTE_SCALE", "REMOTE_BIT_DATA", "USER_DEFINED", "CREATE_TIME", "REMARKS") AS
select 
type_mapping, typeschema, typename, typeid, sourcetypeid, definer, 
lower_len, upper_len, lower_scale, upper_scale, s_opr_p, bit_data, 
wrapname, servername, servertype, serverversion, remote_typeschema, 
remote_typename, remote_meta_type, remote_lower_len, remote_lower_scale, 
remote_bit_data, user_defined, create_time, remarks 
from sysibm.systypemappings;

CREATE VIEW "SYSIBM"."SYSROUTINEPROPERTIESJAVA" ("ROUTINE_ID", "CLASS", "JAR_ID", "JARSCHEMA", "JAR_SIGNATURE") AS
select 
routine_id, class, jar_id, jarschema, jar_signature 
from sysibm.sysroutineproperties;

CREATE VIEW "SYSIBM"."TABLES" ("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "SELF_REFERENCING_COLUMN_NAME", "REFERENCE_GENERATION", "USER_DEFINED_TYPE_CATALOG", "USER_DEFINED_TYPE_SCHEMA", "USER_DEFINED_TYPE_NAME", "IS_INSERTABLE_INTO") AS
WITH T_ALIAS (A_SCHEMA, A_NAME, B_SCHEMA, B_NAME, NUM) AS 
( 
SELECT CREATOR, NAME, BASE_SCHEMA, BASE_NAME, 1 
FROM        SYSIBM.SYSTABLES T 
WHERE  T.TYPE='A' 
UNION ALL 
SELECT  A_SCHEMA, A_NAME, BASE_SCHEMA, BASE_NAME, NUM+1 
FROM T_ALIAS, 
SYSIBM.SYSTABLES 
WHERE B_SCHEMA = CREATOR 
AND B_NAME = NAME 
AND NUM <= 128 
), 
T_ALIAS2 (A2_SCHEMA, A2_NAME, READONLY) AS 
( 
SELECT A_SCHEMA, A_NAME, READONLY 
FROM     T_ALIAS, SYSIBM.SYSVIEWS 
WHERE B_SCHEMA = CREATOR 
AND B_NAME = NAME 
) 
SELECT CAST(CURRENT SERVER AS VARCHAR(128)), 
T.CREATOR , 
T.NAME , 
CASE  TYPE 
WHEN 'A' THEN 'ALIAS' 
WHEN 'H' THEN 'HIERARCHY TABLE' 
WHEN 'J' THEN 'HIERARCHY VIEW' 
WHEN 'S' THEN 'MATERIALIZED QUERY TABLE' 
WHEN 'T' THEN 'BASE TABLE' 
WHEN 'U' THEN 'TYPED TABLE' 
WHEN 'V' THEN 'VIEW' 
WHEN 'W' THEN 'TYPED VIEW' ELSE CAST('' AS VARCHAR(128)) 
END , 
P.COLNAME, 
CASE SUBSTR(P.SPECIAL_PROPS,2,1) 
WHEN 'U' THEN  'USER GENERATED' 
WHEN 'S' THEN  'SYSTEM GENERATED' 
ELSE CAST(NULL AS VARCHAR(16)) 
END, 
CASE 
WHEN T.TYPE IN ('U', 'W') THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN T.TYPE IN ('U', 'W') THEN  ROWTYPESCHEMA 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN T.TYPE IN ('U', 'W') THEN CAST(ROWTYPENAME AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END, 
CASE 
WHEN TYPE='A' AND (A2.READONLY='N' OR A2.READONLY  IS NULL) 
THEN 'YES' 
WHEN TYPE='A' AND A2.READONLY='Y' THEN 'NO' 
WHEN TYPE='G' THEN 'YES' 
WHEN TYPE='H' THEN 'NO' 
WHEN TYPE='J' THEN 'NO' 
WHEN TYPE='S' AND SUBSTR(PROPERTY,1,1)<>'Y' THEN 'NO' 
WHEN TYPE='S' AND SUBSTR(PROPERTY,1,1) ='Y' THEN 'YES' 
WHEN TYPE='T' THEN 'YES' 
WHEN TYPE='U' THEN 'YES' 
WHEN TYPE IN ('V','W') AND V.READONLY='Y' THEN 'NO' 
WHEN TYPE IN ('V','W') AND V.READONLY='N' THEN 'YES' ELSE 'NO' 
END 
FROM ( SYSIBM.SYSTABLES  T 
LEFT OUTER JOIN 
SYSIBM.SYSCOLPROPERTIES P 
ON (T.CREATOR, T.NAME) = (P.TABSCHEMA, P.TABNAME) 
AND SUBSTR(P.SPECIAL_PROPS,1,1) = 'Y' 
) 
LEFT OUTER JOIN 
SYSIBM.SYSVIEWS V 
ON (T.CREATOR, T.NAME) = (V.CREATOR, V.NAME) 
LEFT OUTER JOIN 
T_ALIAS2 A2 
ON (T.CREATOR, T.NAME) = (A2_SCHEMA, A2_NAME);

CREATE VIEW "SYSIBM"."TABLES_S" ("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "SELF_REF_COL_NAME", "REF_GENERATION", "UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "IS_INSERTABLE_INTO") AS
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, 
SELF_REFERENCING_COLUMN_NAME, REFERENCE_GENERATION, 
USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_SCHEMA, 
USER_DEFINED_TYPE_NAME ,  IS_INSERTABLE_INTO 
FROM SYSIBM.TABLES;

CREATE VIEW "SYSIBM"."TABLE_CONSTRAINTS" ("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "CONSTRAINT_NAME", "TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "CONSTRAINT_TYPE", "IS_DEFERRABLE", "INITIALLY_DEFERRED") AS
SELECT CAST(CURRENT SERVER  AS VARCHAR(128)), 
TBCREATOR , 
CAST(NAME    AS VARCHAR(128)), 
CAST(CURRENT SERVER AS VARCHAR(128)), 
TBCREATOR , 
TBNAME, 
CASE CONSTRAINTYP 
WHEN 'K' THEN  'CHECK' 
WHEN 'P' THEN ' PRIMARY KEY' 
WHEN 'F' THEN ' FOREIGN KEY' 
WHEN 'U' THEN ' UNIQUE' 
END , 
'NO'  ,  'NO' 
FROM   SYSIBM.SYSTABCONST 
UNION ALL 
SELECT  CAST(CURRENT SERVER AS VARCHAR(128)), 
TBCREATOR, 
CAST(CONCAT(SUBSTR(HEX(CTIME),5), 
CONCAT(HEX(COLNO), 
CONCAT(HEX(FID),HEX(TID)))) 
AS VARCHAR(128) ), 
CAST(CURRENT SERVER AS VARCHAR(128)), 
TBCREATOR, 
TBNAME, 
'CHECK', 
'NO', 'NO' 
FROM SYSIBM.SYSCOLUMNS C, SYSIBM.SYSTABLES T 
WHERE   C.TBCREATOR = T.CREATOR 
AND C.TBNAME = T.NAME 
AND TYPE IN ('U', 'T') 
AND NULLS ='N';

CREATE VIEW "SYSIBM"."USER_DEFINED_TYPES" ("USER_DEFINED_TYPE_CATALOG", "USER_DEFINED_TYPE_SCHEMA", "USER_DEFINED_TYPE_NAME", "USER_DEFINED_TYPE_CATEGORY", "IS_INSTANTIABLE", "IS_FINAL", "ORDERING_FORM", "ORDERING_CATEGORY", "ORDERING_ROUTINE_CATALOG", "ORDERING_ROUTINE_SCHEMA", "ORDERING_ROUTINE_NAME", "REFERENCE_TYPE", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH", "CHARACTER_OCTET_LENGTH", "CHARACTER_SET_CATALOG", "CHARACTER_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PRECISION_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "SOURCE_DTD_IDENTIFIER", "REF_DTD_IDENTIFIER") AS
SELECT CAST(CURRENT SERVER AS VARCHAR(128)) AS USER_DEFINED_TYPE_CATALOG, 
D.SCHEMA AS USER_DEFINED_TYPE_SCHEMA, 
CAST(D.NAME AS VARCHAR(128)) AS USER_DEFINED_TYPE_NAME, 
CASE D.METATYPE 
WHEN 'T'  THEN 'DISTINCT' 
WHEN 'R' THEN  'STRUCTURED' 
END AS USER_DEFINED_TYPE_CATEGORY, 
CASE D.INSTANTIABLE 
WHEN 'Y'  THEN 'YES' 
WHEN 'N'  THEN 'NO' 
END AS IS_INSTANTIABLE, 
CASE D.FINAL 
WHEN 'Y'  THEN 'YES' 
WHEN 'N' THEN 'NO' 
END AS IS_FINAL, 
CASE 
WHEN D.METATYPE='R' OR (D.METATYPE='T' AND 
D.SOURCETYPE IN ('BLOB','CLOB','DBCLOB','LONG VARCHAR', 
'LONG VARGRAPHIC','DATALINK')) 
THEN CAST('NONE' AS VARCHAR(6)) ELSE 'FULL' 
END AS ORDERING_FORM, 
CASE D.METATYPE 
WHEN 'R' THEN 'STATE'  ELSE CAST('MAP' AS VARCHAR(5)) 
END AS ORDERING_CATEGORY, 
CASE 
WHEN D.METATYPE='R' OR (D.METATYPE='T' AND 
D.SOURCETYPE IN ('BLOB','CLOB','DBCLOB','LONG VARCHAR', 
'LONG VARGRAPHIC','DATALINK') )  THEN CAST(NULL AS VARCHAR(128)) 
ELSE CURRENT SERVER 
END AS ORDERING_ROUTINE_CATALOG, 
CASE 
WHEN D.METATYPE='R' OR (D.METATYPE='T' AND 
D.SOURCETYPE IN ('BLOB','CLOB','DBCLOB','LONG VARCHAR', 
'LONG VARGRAPHIC','DATALINK') ) THEN CAST(NULL AS VARCHAR(128)) 
ELSE D.SOURCESCHEMA 
END AS ORDERING_ROUTINE_SCHEMA, 
CASE 
WHEN D.METATYPE='R' OR (D.METATYPE='T' AND 
D.SOURCETYPE IN ('BLOB','CLOB','DBCLOB','LONG VARCHAR', 
'LONG VARGRAPHIC','DATALINK') )  THEN CAST(NULL AS VARCHAR(128)) 
ELSE D.SOURCETYPE 
END AS ORDERING_ROUTINE_NAME, 
CASE D.METATYPE 
WHEN 'R'    THEN 'USER GENERATED' ELSE CAST(NULL AS VARCHAR(16)) 
END AS REFERENCE_TYPE, 
CASE 
WHEN D.SOURCETYPE ='CHARACTER'       THEN 'CHARACTER' 
WHEN D.SOURCETYPE ='VARCHAR'         THEN 'CHARACTER VARYING' 
WHEN D.SOURCETYPE ='LONG VARCHAR'    THEN 'LONG VARCHAR' 
WHEN D.SOURCETYPE ='INTEGER'         THEN 'INTEGER' 
WHEN D.SOURCETYPE ='SMALLINT'        THEN 'SMALLINT' 
WHEN D.SOURCETYPE ='BIGINT'          THEN 'BIGINT' 
WHEN D.SOURCETYPE ='REAL'            THEN 'REAL' 
WHEN D.SOURCETYPE ='DOUBLE'          THEN 'DOUBLE PRECISION' 
WHEN D.SOURCETYPE ='DECIMAL'         THEN 'DECIMAL' 
WHEN D.SOURCETYPE ='BLOB'            THEN 'BINARY LARGE OBJECT' 
WHEN D.SOURCETYPE ='CLOB'            THEN 'CHARACTER LARGE OBJECT' 
WHEN D.SOURCETYPE ='DBCLOB'  THEN 'DOUBLE-BYTE CHARACTER LARGE OBJECT' 
WHEN D.SOURCETYPE ='GRAPHIC'         THEN 'GRAPHIC' 
WHEN D.SOURCETYPE ='VARGRAPHIC'      THEN 'GRAPHIC VARYING' 
WHEN D.SOURCETYPE ='LONG VARGRAPHIC' THEN 'LONG VARGRAPHIC' 
WHEN D.SOURCETYPE ='DATALINK'        THEN 'DATALINK' 
WHEN D.SOURCETYPE ='TIME'            THEN 'TIME' 
WHEN D.SOURCETYPE ='DATE'            THEN 'DATE' 
WHEN D.SOURCETYPE ='TIMESTAMP'       THEN 'TIMESTAMP' 
ELSE D.SOURCETYPE 
END 
AS DATA_TYPE, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'BLOB', 'DBCLOB', 
'GRAPHIC', 'VARGRAPHIC', 'LONG VARGRAPHIC') THEN D.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END AS CHARACTER_MAXIMUM_LENGTH, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'BLOB') THEN D.LENGTH 
WHEN D.SOURCETYPE IN ('DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') THEN D.LENGTH*2 
ELSE CAST(NULL AS INTEGER) 
END AS CHARACTER_OCTET_LENGTH, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END AS CHARACTER_SET_CATALOG, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END AS CHARACTER_SET_SCHEMA, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST(CONCAT('IBM', CHAR(D.CODEPAGE)) AS VARCHAR(128)) 
ELSE CAST( NULL AS VARCHAR(128)) 
END AS CHARACTER_SET_NAME, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST(CURRENT SERVER AS VARCHAR(128)) 
ELSE NULL 
END AS COLLATION_CATALOG, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST('SYSIBM' AS VARCHAR(128)) 
ELSE NULL 
END AS COLLATION_SCHEMA, 
CASE 
WHEN D.SOURCETYPE IN ('CHARACTER', 'VARCHAR', 'LONG VARCHAR', 
'CLOB', 'DBCLOB', 'GRAPHIC', 
'VARGRAPHIC', 'LONG VARGRAPHIC') 
THEN CAST('IBMDEFAULT' AS VARCHAR(128)) 
ELSE NULL 
END AS COLLATION_NAME, 
CASE 
WHEN D.SOURCETYPE = 'INTEGER'  THEN 10 
WHEN D.SOURCETYPE = 'BIGINT'   THEN 19 
WHEN D.SOURCETYPE = 'SMALLINT' THEN 5 
WHEN D.SOURCETYPE = 'REAL'     THEN 24 
WHEN D.SOURCETYPE = 'DOUBLE'   THEN 53 
WHEN D.SOURCETYPE = 'DECIMAL'  THEN D.LENGTH 
ELSE CAST(NULL AS INTEGER) 
END AS NUMERIC_PRECISION, 
CASE 
WHEN D.SOURCETYPE IN ('INTEGER', 'BIGINT', 'SMALLINT', 'DECIMAL') 
THEN 10 
WHEN D.SOURCETYPE IN('REAL', 'DOUBLE') 
THEN 2 
ELSE CAST(NULL AS INTEGER) 
END AS NUMERIC_PRECISION_RADIX, 
CASE 
WHEN D.SOURCETYPE ='DECIMAL' THEN  CAST(D.SCALE AS INTEGER) 
WHEN D.SOURCETYPE IN ('INTEGER', 'SMALLINT')  THEN 0 
ELSE CAST(NULL AS INTEGER) 
END AS NUMERIC_SCALE, 
CASE 
WHEN D.SOURCETYPE IN ('DATE','TIME') THEN 0 
WHEN D.SOURCETYPE = 'TIMESTAMP'      THEN CAST(D.SCALE AS INTEGER) 
ELSE CAST(NULL AS INTEGER) 
END AS DATETIME_PRECISION, 
CAST(NULL AS VARCHAR(128)) AS INTERVAL_TYPE, 
CAST(NULL AS INTEGER) AS INTERVAL_PRECISION, 
CASE 
WHEN D.METATYPE='T' 
THEN CAST(CONCAT('D',HEX(D.TYPEID)) AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END AS SOURCE_DTD_IDENTIFIER, 
CASE 
WHEN D.METATYPE='R' 
THEN CAST(CONCAT('D',HEX(D.TYPEID)) AS VARCHAR(128)) 
ELSE CAST(NULL AS VARCHAR(128)) 
END AS REF_DTD_IDENTIFIER 
FROM SYSIBM.SYSDATATYPES D 
WHERE D.METATYPE IN ('T', 'R');

CREATE VIEW "SYSIBM"."UDT_S" ("UDT_CATALOG", "UDT_SCHEMA", "UDT_NAME", "UDT_CATEGORY", "IS_INSTANTIABLE", "IS_FINAL", "ORDERING_FORM", "ORDERING_CATEGORY", "ORDERING_ROUT_CAT", "ORDERING_ROUT_SCH", "ORDERING_ROUT_NAME", "REFERENCE_TYPE", "DATA_TYPE", "CHAR_MAX_LENGTH", "CHAR_OCTET_LENGTH", "CHAR_SET_CATALOG", "CHAR_SET_SCHEMA", "CHARACTER_SET_NAME", "COLLATION_CATALOG", "COLLATION_SCHEMA", "COLLATION_NAME", "NUMERIC_PRECISION", "NUMERIC_PREC_RADIX", "NUMERIC_SCALE", "DATETIME_PRECISION", "INTERVAL_TYPE", "INTERVAL_PRECISION", "SOURCE_DTD_ID", "REF_DTD_IDENTIFIER") AS
SELECT USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_SCHEMA, 
USER_DEFINED_TYPE_NAME, USER_DEFINED_TYPE_CATEGORY, 
IS_INSTANTIABLE, IS_FINAL, ORDERING_FORM, ORDERING_CATEGORY, 
ORDERING_ROUTINE_CATALOG, ORDERING_ROUTINE_SCHEMA, 
ORDERING_ROUTINE_NAME, REFERENCE_TYPE, DATA_TYPE, 
CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, 
CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, 
CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, 
COLLATION_NAME, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, 
NUMERIC_SCALE, DATETIME_PRECISION, INTERVAL_TYPE, 
INTERVAL_PRECISION, SOURCE_DTD_IDENTIFIER, REF_DTD_IDENTIFIER 
FROM SYSIBM.USER_DEFINED_TYPES;

CREATE VIEW "SYSIBM"."VIEWS" ("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "VIEW_DEFINITION", "CHECK_OPTION", "IS_UPDATABLE") AS
SELECT CAST(CURRENT SERVER AS VARCHAR(128)), V.CREATOR , V.NAME , V.TEXT, 
CASE V.CHECK 
WHEN 'N' THEN 'NONE' 
WHEN 'L' THEN 'LOCAL' 
WHEN 'C' THEN 'CASCADED' 
END , 
CASE V.READONLY 
WHEN 'Y' THEN 'NO' 
WHEN 'N' THEN 'YES' 
END 
FROM SYSIBM.SYSVIEWS V,SYSIBM.SYSTABLES T 
WHERE V.CREATOR=T.CREATOR AND V.NAME=T.NAME AND T.TYPE='V';

CREATE VIEW "SYSIBMADM"."ADMINTABCOMPRESSINFO" ("TABSCHEMA", "TABNAME", "DBPARTITIONNUM", "DATA_PARTITION_ID", "COMPRESS_ATTR", "DICT_BUILDER", "DICT_BUILD_TIMESTAMP", "COMPRESS_DICT_SIZE", "EXPAND_DICT_SIZE", "ROWS_SAMPLED", "PAGES_SAVED_PERCENT", "BYTES_SAVED_PERCENT", "AVG_COMPRESS_REC_LENGTH", "OBJECT_TYPE") AS
SELECT  TABINFO.TABSCHEMA, TABINFO.TABNAME, TABINFO.DBPARTITIONNUM,  TABINFO.DATA_PARTITION_ID, TABINFO.COMPRESS_ATTR,  TABINFO.DICT_BUILDER, TABINFO.DICT_BUILD_TIMESTAMP,  TABINFO.COMPRESS_DICT_SIZE, TABINFO.EXPAND_DICT_SIZE,  TABINFO.ROWS_SAMPLED, TABINFO.PAGES_SAVED_PERCENT,  TABINFO.BYTES_SAVED_PERCENT, TABINFO.AVG_COMPRESS_REC_LENGTH,  TABINFO.OBJECT_TYPE FROM TABLE(SYSPROC.ADMIN_GET_TAB_COMPRESS_INFO_V97( '', '','')) AS TABINFO;

CREATE VIEW "SYSIBMADM"."ADMINTABINFO" ("TABSCHEMA", "TABNAME", "TABTYPE", "DBPARTITIONNUM", "DATA_PARTITION_ID", "AVAILABLE", "DATA_OBJECT_L_SIZE", "DATA_OBJECT_P_SIZE", "INDEX_OBJECT_L_SIZE", "INDEX_OBJECT_P_SIZE", "LONG_OBJECT_L_SIZE", "LONG_OBJECT_P_SIZE", "LOB_OBJECT_L_SIZE", "LOB_OBJECT_P_SIZE", "XML_OBJECT_L_SIZE", "XML_OBJECT_P_SIZE", "INDEX_TYPE", "REORG_PENDING", "INPLACE_REORG_STATUS", "LOAD_STATUS", "READ_ACCESS_ONLY", "NO_LOAD_RESTART", "NUM_REORG_REC_ALTERS", "INDEXES_REQUIRE_REBUILD", "LARGE_RIDS", "LARGE_SLOTS", "DICTIONARY_SIZE", "BLOCKS_PENDING_CLEANUP", "STATSTYPE", "XML_RECORD_TYPE", "RECLAIMABLE_SPACE", "XML_DICTIONARY_SIZE") AS
SELECT  TABINFO.TABSCHEMA, TABINFO.TABNAME, TABINFO.TABTYPE,  TABINFO.DBPARTITIONNUM, TABINFO.DATA_PARTITION_ID, TABINFO.AVAILABLE,  TABINFO.DATA_OBJECT_L_SIZE, TABINFO.DATA_OBJECT_P_SIZE,  TABINFO.INDEX_OBJECT_L_SIZE, TABINFO.INDEX_OBJECT_P_SIZE,  TABINFO.LONG_OBJECT_L_SIZE, TABINFO.LONG_OBJECT_P_SIZE,  TABINFO.LOB_OBJECT_L_SIZE, TABINFO.LOB_OBJECT_P_SIZE,  TABINFO.XML_OBJECT_L_SIZE, TABINFO.XML_OBJECT_P_SIZE,  TABINFO.INDEX_TYPE, TABINFO.REORG_PENDING, TABINFO.INPLACE_REORG_STATUS,  TABINFO.LOAD_STATUS, TABINFO.READ_ACCESS_ONLY, TABINFO.NO_LOAD_RESTART,  TABINFO.NUM_REORG_REC_ALTERS, TABINFO.INDEXES_REQUIRE_REBUILD, TABINFO.LARGE_RIDS,  TABINFO.LARGE_SLOTS, TABINFO.DICTIONARY_SIZE, TABINFO.BLOCKS_PENDING_CLEANUP,  TABINFO.STATSTYPE, TABINFO.XML_RECORD_TYPE, TABINFO.RECLAIMABLE_SPACE,  TABINFO.XML_DICTIONARY_SIZE FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO_V97( '', '')) AS TABINFO;

CREATE VIEW "SYSIBMADM"."ADMINTEMPCOLUMNS" ("APPLICATION_HANDLE", "TABSCHEMA", "TABNAME", "COLNAME", "COLNO", "TYPESCHEMA", "TYPENAME", "LENGTH", "SCALE", "DEFAULT", "NULLS", "CODEPAGE", "LOGGED", "COMPACT", "INLINE_LENGTH", "IDENTITY", "GENERATED") AS
SELECT T.APPLICATION_HANDLE, T.TABSCHEMA, T.TABNAME, T.COLNAME, T.COLNO, T.TYPESCHEMA, T.TYPENAME, T.LENGTH, T.SCALE, T.DEFAULT, T.NULLS, T.CODEPAGE, T.LOGGED, T.COMPACT, T.INLINE_LENGTH, T.IDENTITY, T.GENERATED FROM TABLE(SYSPROC.ADMIN_GET_TEMP_COLUMNS(CAST (NULL AS BIGINT), NULL, NULL)) T;

CREATE VIEW "SYSIBMADM"."ADMINTEMPTABLES" ("APPLICATION_HANDLE", "APPLICATION_NAME", "TABSCHEMA", "TABNAME", "INSTANTIATOR", "INSTANTIATORTYPE", "TEMPTABTYPE", "INSTANTIATION_TIME", "COLCOUNT", "TAB_FILE_ID", "TBSP_ID", "PMAP_ID", "PARTITION_MODE", "CODEPAGE", "ONCOMMIT", "ONROLLBACK", "LOGGED") AS
SELECT T.APPLICATION_HANDLE, T.APPLICATION_NAME, T.TABSCHEMA, T.TABNAME, T.INSTANTIATOR, T.INSTANTIATORTYPE, T.TEMPTABTYPE, T.INSTANTIATION_TIME, T.COLCOUNT, T.TAB_FILE_ID, T.TBSP_ID, T.PMAP_ID, T.PARTITION_MODE, T.CODEPAGE , T.ONCOMMIT , T.ONROLLBACK , T.LOGGED   FROM TABLE (SYSPROC.ADMIN_GET_TEMP_TABLES(CAST (NULL AS BIGINT), NULL, NULL)) T;

CREATE VIEW "SYSIBMADM"."DBA_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
WITH DATAPARTS (TABSCHEMA, TABNAME, TOTAL_PARTS)      AS ( SELECT DP.TABSCHEMA, DP.TABNAME, COUNT(*)        FROM SYSCAT.DATAPARTITIONS DP        GROUP BY DP.TABSCHEMA, DP.TABNAME) SELECT   TAB.OWNER  ,TAB.TABSCHEMA  ,TAB.TABNAME  ,TAB.TBSPACE   ,PCTFREE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,0  ,CAST( CASE TAB.LOGGED   WHEN 'N' THEN 'NO'   ELSE 'YES'   END AS VARCHAR(3) )  ,CARD  ,TAB.NPAGES  ,TAB.FPAGES - TAB.NPAGES  ,AVGROWSIZE  ,CAST( CASE LOCKSIZE   WHEN 'T' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) )  ,STATS_TIME  ,CAST( CASE    WHEN DP.TOTAL_PARTS > 0 THEN 'YES'   WHEN PARTITION_MODE = 'H' THEN 'YES'   WHEN PARTITION_MODE = 'R' THEN 'YES'   ELSE 'NO'   END AS VARCHAR(3) )  ,CAST( CASE TYPE   WHEN 'G' THEN 'Y'   ELSE 'N'   END AS VARCHAR(1) )  ,BP.BPNAME  ,CAST( 'YES' AS VARCHAR(3) )  ,CAST( CASE COMPRESSION   WHEN 'B' THEN 'ENABLED'   WHEN 'R' THEN 'ENABLED'   WHEN 'V' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) ) FROM SYSCAT.TABLES TAB LEFT JOIN DATAPARTS DP ON TAB.TABSCHEMA = DP.TABSCHEMA AND TAB.TABNAME = DP.TABNAME LEFT JOIN SYSCAT.TABLESPACES TBS ON TBS.TBSPACEID = TAB.TBSPACEID LEFT JOIN SYSCAT.BUFFERPOOLS BP ON BP.BUFFERPOOLID = TBS.BUFFERPOOLID WHERE TAB.TYPE NOT IN ('A','V','W','N');

CREATE VIEW "SYSIBMADM"."ALL_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_TABLES TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (TAB.TABLE_SCHEMA = ATAB.TABSCHEMA AND TAB.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_ALL_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
SELECT * FROM SYSIBMADM.ALL_TABLES;

CREATE VIEW "SYSIBMADM"."ALL_ARGUMENTS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "PACKAGE_NAME", "OBJECT_ID", "ARGUMENT_NAME", "SEQUENCE", "DATA_TYPE", "IN_OUT", "DATA_LENGTH", "DATA_SCALE") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE AND RTAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_MODULES (MODULESCHEMA, MODULENAME, ACCESSIBLE)     AS (SELECT MODULESCHEMA, MODULENAME, 'Y'         FROM SYSCAT.MODULEAUTH MODAUTH, ALL_IDS IDS         WHERE IDS.ID = MODAUTH.GRANTEE AND IDS.TYPE = MODAUTH.GRANTEETYPE AND EXECUTEAUTH != 'N') SELECT    RT.OWNER   ,RP.ROUTINESCHEMA   ,RP.ROUTINENAME   ,RP.ROUTINEMODULENAME   ,RT.ROUTINEID   ,RP.PARMNAME   ,RP.ORDINAL   ,RP.TYPENAME   ,CAST( CASE RP.ROWTYPE    WHEN 'B' THEN 'IN/OUT'    WHEN 'O' THEN 'OUT'    WHEN 'P' THEN 'IN'    END AS VARCHAR(6) )  ,RP.LENGTH   ,RP.SCALE  FROM SYSCAT.ROUTINEPARMS RP  JOIN SYSCAT.ROUTINES RT ON RP.ROUTINESCHEMA = RT.ROUTINESCHEMA AND RP.ROUTINENAME = RT.ROUTINENAME  JOIN ACCESSIBLE_ROUTINES ROUTAUTH ON RT.ROUTINESCHEMA = ROUTAUTH.RTSCHEMA AND RT.SPECIFICNAME = ROUTAUTH.RTSPECIFICNAME WHERE RP.ROWTYPE IN ('B','O','P') AND (ROUTAUTH.ACCESSIBLE = 'Y' OR RT.OWNER = CURRENT USER);

CREATE VIEW "SYSIBMADM"."ALL_CATALOG" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_SEQUENCES (SEQSCHEMA, SEQNAME, ACCESSIBLE)     AS (SELECT SEQSCHEMA, SEQNAME, 'Y'         FROM SYSCAT.SEQUENCEAUTH SEQAUTH, ALL_IDS IDS         WHERE IDS.ID = SEQAUTH.GRANTEE AND IDS.TYPE = SEQAUTH.GRANTEETYPE AND USAGEAUTH != 'N'),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')),     ACCESSIBLE_MODULES (MODULESCHEMA, MODULENAME, ACCESSIBLE)     AS (SELECT MODULESCHEMA, MODULENAME, 'Y'         FROM SYSCAT.MODULEAUTH MODAUTH, ALL_IDS IDS         WHERE IDS.ID = MODAUTH.GRANTEE AND IDS.TYPE = MODAUTH.GRANTEETYPE AND EXECUTEAUTH != 'N') SELECT OWNER, SEQ.SEQSCHEMA, SEQ.SEQNAME,        CAST( CASE WHEN SEQTYPE = 'A' THEN 'SYNONYM'       ELSE 'SEQUENCE'       END AS VARCHAR(8) ) FROM SYSCAT.SEQUENCES SEQ JOIN ACCESSIBLE_SEQUENCES AUTH ON      AUTH.SEQSCHEMA = SEQ.SEQSCHEMA AND AUTH.SEQNAME = SEQ.SEQNAME WHERE AUTH.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER UNION ALL SELECT OWNER, TAB.TABSCHEMA, TAB.TABNAME,       CASE WHEN (TYPE = 'V' OR TYPE = 'W') THEN 'VIEW'            WHEN TYPE = 'A' THEN 'SYNONYM'            ELSE 'TABLE' END FROM SYSCAT.TABLES TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB  ON (TAB.TABSCHEMA = ATAB.TABSCHEMA AND TAB.TABNAME = ATAB.TABNAME) WHERE TAB.TYPE != 'N' AND ATAB.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER UNION ALL SELECT OWNER, MOD.MODULESCHEMA, MOD.MODULENAME, 'SYNONYM' FROM SYSCAT.MODULES MOD JOIN ACCESSIBLE_MODULES AUTH  ON (MOD.MODULESCHEMA = AUTH.MODULESCHEMA AND MOD.MODULENAME = AUTH.MODULENAME) WHERE MOD.MODULETYPE = 'A';

CREATE VIEW "SYSIBMADM"."DBA_COL_COMMENTS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COMMENTS") AS
SELECT   T.OWNER  ,C.TABSCHEMA  ,C.TABNAME  ,C.COLNAME  ,C.REMARKS FROM SYSCAT.COLUMNS C, SYSCAT.TABLES T WHERE C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME=T.TABNAME;

CREATE VIEW "SYSIBMADM"."ALL_COL_COMMENTS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COMMENTS") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_COL_COMMENTS TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (TAB.TABLE_SCHEMA = ATAB.TABSCHEMA AND TAB.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_CONSTRAINTS" ("OWNER", "CONSTRAINT_NAME", "CONSTRAINT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "R_OWNER", "R_CONSTRAINT_NAME", "DELETE_RULE", "STATUS", "DEFERRED", "VALIDATED", "GENERATED", "RELY", "INDEX_OWNER", "INDEX_NAME") AS
SELECT   TC.OWNER  ,TC.CONSTNAME  ,CAST( CASE TC.TYPE   WHEN 'F' THEN 'R'   WHEN 'K' THEN 'C'   WHEN 'P' THEN 'P'   WHEN 'U' THEN 'U'   ELSE TC.TYPE   END AS VARCHAR(1) )  ,TC.TABSCHEMA  ,TC.TABNAME  ,TAB.OWNER  ,REFS.REFKEYNAME  ,CAST( CASE REFS.DELETERULE   WHEN 'A' THEN 'NO ACTION'   WHEN 'C' THEN 'CASCADE'   WHEN 'N' THEN 'SET NULL'   WHEN 'R' THEN 'RESTRICT'   END AS VARCHAR(9) )  ,CAST( CASE TC.ENFORCED   WHEN 'Y' THEN 'ENABLED'   WHEN 'N' THEN 'DISABLED'   END AS VARCHAR(8) )  ,CAST( CASE TC.ENFORCED   WHEN 'Y' THEN 'IMMEDIATE'   WHEN 'N' THEN 'DEFERRED'   END AS VARCHAR(9) )  ,CAST( CASE TC.CHECKEXISTINGDATA   WHEN 'I' THEN 'VALIDATED'   WHEN 'D' THEN 'VALIDATED'   WHEN 'N' THEN 'NOT VALIDATED'   END AS VARCHAR(13) )  ,CAST( CASE WHEN (TC.OWNERTYPE = 'S') OR (TC.CONSTNAME LIKE 'SQL%' AND LENGTH(TC.CONSTNAME) = 18) THEN 'Y'        ELSE 'N'   END AS VARCHAR(1) )  ,TC.ENABLEQUERYOPT  ,DEP.BSCHEMA  ,DEP.BNAME FROM SYSCAT.TABCONST TC INNER JOIN SYSCAT.TABLES TAB ON TC.TABSCHEMA = TAB.TABSCHEMA AND TC.TABNAME = TAB.TABNAME  LEFT OUTER JOIN SYSCAT.CONSTDEP DEP ON TC.CONSTNAME = DEP.CONSTNAME AND TC.TABSCHEMA = DEP.TABSCHEMA AND TC.TABNAME = DEP.TABNAME AND DEP.BTYPE = 'I'  LEFT OUTER JOIN SYSCAT.REFERENCES  REFS ON TC.CONSTNAME = REFS.CONSTNAME AND TC.TABSCHEMA = REFS.TABSCHEMA AND TC.TABNAME = REFS.TABNAME;

CREATE VIEW "SYSIBMADM"."ALL_CONSTRAINTS" ("OWNER", "CONSTRAINT_NAME", "CONSTRAINT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "R_OWNER", "R_CONSTRAINT_NAME", "DELETE_RULE", "STATUS", "DEFERRED", "VALIDATED", "GENERATED", "RELY", "INDEX_OWNER", "INDEX_NAME") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT CONS.* FROM SYSIBMADM.DBA_CONSTRAINTS CONS LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (CONS.TABLE_SCHEMA = ATAB.TABSCHEMA AND CONS.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR CONS.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_CONS_COLUMNS" ("OWNER", "CONSTRAINT_NAME", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "POSITION") AS
SELECT   TC.OWNER  ,TC.CONSTNAME  ,TC.TABSCHEMA  ,TC.TABNAME  ,KC.COLNAME  ,KC.COLSEQ FROM SYSCAT.TABCONST TC, SYSCAT.KEYCOLUSE KC WHERE TC.CONSTNAME = KC.CONSTNAME AND TC.TABSCHEMA = KC.TABSCHEMA AND TC.TABNAME = KC.TABNAME;

CREATE VIEW "SYSIBMADM"."ALL_CONS_COLUMNS" ("OWNER", "CONSTRAINT_NAME", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "POSITION") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT CONS.* FROM SYSIBMADM.DBA_CONS_COLUMNS CONS LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (CONS.TABLE_SCHEMA = ATAB.TABSCHEMA AND CONS.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR CONS.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_DEPENDENCIES" ("OWNER", "SCHEMA", "NAME", "TYPE", "REFERENCED_SCHEMA", "REFERENCED_NAME", "REFERENCED_TYPE") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_PACKAGES (PKGSCHEMA, PKGNAME, ACCESSIBLE)     AS (SELECT PKGSCHEMA, PKGNAME, 'Y'         FROM SYSCAT.PACKAGEAUTH PKGAUTH, ALL_IDS IDS         WHERE IDS.ID = PKGAUTH.GRANTEE AND IDS.TYPE = PKGAUTH.GRANTEETYPE AND PKGAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_VARIABLES (VARSCHEMA, VARNAME, ACCESSIBLE)     AS (SELECT VARSCHEMA, VARNAME, 'Y'         FROM SYSCAT.VARIABLEAUTH VARAUTH, ALL_IDS IDS         WHERE IDS.ID = VARAUTH.GRANTEE AND IDS.TYPE = VARAUTH.GRANTEETYPE AND          (VARAUTH.READAUTH != 'N' AND VARAUTH.WRITEAUTH != 'N')),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE AND RTAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TC.OWNER, CAST( NULL AS VARCHAR(128) ), CD.CONSTNAME, CAST( 'CONSTRAINT' AS VARCHAR(15) ),       CD.BSCHEMA, CD.BNAME,       CAST( CASE CD.BTYPE          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'R' THEN 'STRUCTURED TYPE'       END AS VARCHAR(20) ) FROM SYSCAT.CONSTDEP CD, SYSCAT.TABCONST TC LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB  ON TC.TABSCHEMA = ATAB.TABSCHEMA AND TC.TABNAME = ATAB.TABNAME WHERE CD.CONSTNAME = TC.CONSTNAME AND CD.TABSCHEMA = TC.TABSCHEMA   AND CD.TABNAME = TC.TABNAME AND (ATAB.ACCESSIBLE = 'Y' OR TC.OWNER = CURRENT USER) UNION ALL SELECT IX.OWNER, IXDEP.INDSCHEMA, IXDEP.INDNAME, 'INDEX',       IXDEP.BSCHEMA, IXDEP.BNAME,       CASE IXDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.INDEXDEP IXDEP, SYSCAT.INDEXES IX LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB   ON ATAB.TABSCHEMA = IX.TABSCHEMA AND ATAB.TABNAME = IX.TABNAME WHERE IXDEP.INDNAME = IX.INDNAME AND IXDEP.INDSCHEMA = IX.INDSCHEMA  AND (ATAB.ACCESSIBLE = 'Y' OR IX.OWNER = CURRENT USER) UNION ALL SELECT PKG.OWNER, PDEP.PKGSCHEMA, PDEP.PKGNAME, 'DB2 PACKAGE',       PDEP.BSCHEMA, PDEP.BNAME,       CASE PDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'D' THEN 'SERVER DEFINITION'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'M' THEN 'FUNCTION MAPPING'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'P' THEN 'PAGE SIZE'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.PACKAGES PKG, SYSCAT.PACKAGEDEP PDEP     LEFT OUTER JOIN ACCESSIBLE_PACKAGES PAUTH ON PDEP.PKGSCHEMA = PAUTH.PKGSCHEMA        AND PDEP.PKGNAME = PAUTH.PKGNAME WHERE PDEP.PKGSCHEMA = PKG.PKGSCHEMA AND PDEP.PKGNAME = PKG.PKGNAME  AND (PAUTH.ACCESSIBLE = 'Y' OR PKG.OWNER = CURRENT USER) UNION ALL SELECT RT.OWNER, RDEP.ROUTINESCHEMA, RT.ROUTINENAME,       CASE RT.ROUTINETYPE          WHEN 'P' THEN 'PROCEDURE'          WHEN 'F' THEN 'FUNCTION'          WHEN 'M' THEN 'METHOD'       END,       RDEP.BSCHEMA, RDEP.BNAME,       CASE RDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.ROUTINEDEP RDEP, SYSCAT.ROUTINES RT     LEFT OUTER JOIN ACCESSIBLE_ROUTINES AUTH ON RT.ROUTINESCHEMA = AUTH.RTSCHEMA          AND RT.SPECIFICNAME = AUTH.RTSPECIFICNAME WHERE RDEP.ROUTINESCHEMA = RT.ROUTINESCHEMA AND RDEP.SPECIFICNAME = RT.SPECIFICNAME  AND (AUTH.ACCESSIBLE = 'Y'  OR RT.OWNER = CURRENT USER) UNION ALL SELECT TAB.OWNER, TDEP.TABSCHEMA, TDEP.TABNAME,        CASE TAB.TYPE          WHEN 'U' THEN 'VIEW'          WHEN 'V' THEN 'VIEW'          ELSE 'TABLE'       END,       TDEP.BSCHEMA, TDEP.BNAME,       CASE TDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.TABDEP TDEP, SYSCAT.TABLES TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB  ON TAB.TABSCHEMA = ATAB.TABSCHEMA AND TAB.TABNAME = ATAB.TABNAME WHERE TDEP.TABSCHEMA = TAB.TABSCHEMA AND TDEP.TABNAME = TAB.TABNAME  AND (ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER) UNION ALL SELECT TAB.OWNER, TDEP.TABSCHEMA, TDEP.TABNAME, 'TABLE',       TDEP.DEPTABSCHEMA, TDEP.DEPTABNAME, 'TABLE' FROM SYSCAT.TABDETACHEDDEP TDEP, SYSCAT.TABLES TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB  ON TAB.TABSCHEMA = ATAB.TABSCHEMA AND TAB.TABNAME = ATAB.TABNAME WHERE TDEP.TABSCHEMA = TAB.TABSCHEMA AND TDEP.TABNAME = TAB.TABNAME  AND (ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER) UNION ALL SELECT TRG.OWNER, TGDEP.TRIGSCHEMA, TGDEP.TRIGNAME, 'TRIGGER',       TGDEP.BSCHEMA, TGDEP.BNAME,       CASE TGDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.TRIGDEP TGDEP, SYSCAT.TRIGGERS TRG WHERE TGDEP.TRIGSCHEMA = TRG.TRIGSCHEMA AND TGDEP.TRIGNAME = TRG.TRIGNAME UNION ALL SELECT VAR.OWNER, VDEP.VARSCHEMA, VDEP.VARNAME, 'GLOBAL VARIABLE',       VDEP.BSCHEMA, VDEP.BNAME,       CASE VDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.VARIABLEDEP VDEP, SYSCAT.VARIABLES VAR     LEFT OUTER JOIN ACCESSIBLE_VARIABLES VAUTH      ON VAUTH.VARSCHEMA = VAR.VARSCHEMA AND VAUTH.VARNAME = VAR.VARNAME WHERE VDEP.VARSCHEMA = VAR.VARSCHEMA AND VDEP.VARNAME = VAR.VARNAME  AND (VAUTH.ACCESSIBLE = 'Y' OR VAR.OWNER = CURRENT USER);

CREATE VIEW "SYSIBMADM"."ALL_ERRORS" ("OWNER", "SCHEMA", "NAME", "TYPE", "LINE", "TEXT") AS
WITH ALL_IDS (ID, TYPE)     AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE            AND RTAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'            OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')),     ACCESSIBLE_VARIABLES (VARSCHEMA, VARNAME, ACCESSIBLE)     AS (SELECT VARSCHEMA, VARNAME, 'Y'         FROM SYSCAT.VARIABLEAUTH VARAUTH, ALL_IDS IDS         WHERE IDS.ID = VARAUTH.GRANTEE AND IDS.TYPE = VARAUTH.GRANTEETYPE AND         (VARAUTH.READAUTH != 'N' AND VARAUTH.WRITEAUTH != 'N')) SELECT     TRIG.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,CAST( 'TRIGGER' AS VARCHAR(15) )   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.TRIGGERS TRIG WHERE OBJ.OBJECTTYPE = 'B' AND OBJ.OBJECTSCHEMA = TRIG.TRIGSCHEMA AND OBJ.OBJECTNAME = TRIG.TRIGNAME UNION ALL SELECT     TYPE.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'DATATYPE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.DATATYPES TYPE WHERE OBJ.OBJECTTYPE = 'R' AND OBJ.OBJECTSCHEMA = TYPE.TYPESCHEMA AND OBJ.OBJECTNAME = TYPE.TYPENAME UNION ALL SELECT    ROUT.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'ROUTINE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ      JOIN SYSCAT.ROUTINES ROUT ON OBJ.OBJECTSCHEMA = ROUT.ROUTINESCHEMA AND OBJ.OBJECTNAME = ROUT.SPECIFICNAME      LEFT OUTER JOIN ACCESSIBLE_ROUTINES AROUT ON OBJ.OBJECTSCHEMA = AROUT.RTSCHEMA AND OBJ.OBJECTNAME = AROUT.RTSPECIFICNAME WHERE OBJ.OBJECTTYPE = 'F' AND (AROUT.ACCESSIBLE = 'Y' OR CURRENT USER = (SELECT RTN.DEFINER FROM SYSIBM.SYSROUTINES RTN WHERE RTN.ROUTINESCHEMA=OBJ.OBJECTSCHEMA AND RTN.SPECIFICNAME=OBJ.OBJECTNAME)) UNION ALL SELECT    VIEW.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'VIEW'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ      JOIN SYSCAT.VIEWS VIEW ON OBJ.OBJECTSCHEMA = VIEW.VIEWSCHEMA AND OBJ.OBJECTNAME = VIEW.VIEWNAME      LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON OBJ.OBJECTSCHEMA = ATAB.TABSCHEMA AND OBJ.OBJECTNAME = ATAB.TABNAME WHERE OBJ.OBJECTTYPE = 'V' AND (ATAB.ACCESSIBLE = 'Y' OR CURRENT USER  = (SELECT VIEWS.DEFINER FROM SYSIBM.SYSVIEWS VIEWS WHERE   VIEWS.CREATOR=OBJ.OBJECTSCHEMA AND VIEWS.NAME = OBJ.OBJECTNAME)) UNION ALL SELECT    VAR.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'GLOBAL VARIABLE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ      JOIN SYSCAT.VARIABLES VAR ON OBJ.OBJECTSCHEMA = VAR.VARSCHEMA AND OBJ.OBJECTNAME = VAR.VARNAME      LEFT OUTER JOIN ACCESSIBLE_VARIABLES AVAR ON OBJ.OBJECTSCHEMA = AVAR.VARSCHEMA AND OBJ.OBJECTNAME = AVAR.VARNAME WHERE OBJ.OBJECTTYPE = 'v' AND (AVAR.ACCESSIBLE = 'Y' OR CURRENT USER  = (SELECT VAR.OWNER FROM SYSIBM.SYSVARIABLES VAR WHERE  VAR.VARSCHEMA=OBJ.OBJECTSCHEMA AND VAR.VARNAME=OBJ.OBJECTNAME) );

CREATE VIEW "SYSIBMADM"."DBA_INDEXES" ("OWNER", "INDEX_SCHEMA", "INDEX_NAME", "INDEX_TYPE", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "UNIQUENESS", "COMPRESSION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "STATUS", "NUM_ROWS", "LAST_ANALYZED", "PARTITIONED", "GENERATED", "BUFFER_POOL") AS
WITH INDEXPARTS (INDSCHEMA, INDNAME, TOTAL_PARTS)      AS ( SELECT IP.INDSCHEMA, IP.INDNAME, COUNT(*)        FROM SYSCAT.INDEXPARTITIONS IP        GROUP BY IP.INDSCHEMA, IP.INDNAME) SELECT   IDX.OWNER  ,IDX.INDSCHEMA  ,IDX.INDNAME  ,INDEXTYPE  ,TAB.OWNER  ,IDX.TABSCHEMA  ,IDX.TABNAME  ,CAST( 'TABLE' AS VARCHAR(5) )  ,CAST( CASE UNIQUERULE   WHEN 'D' THEN 'NONUNIQUE'   WHEN 'U' THEN 'UNIQUE'   WHEN 'P' THEN 'UNIQUE'   ELSE 'UNKNOWN'   END AS VARCHAR(9) )  ,CAST( CASE IDX.COMPRESSION   WHEN 'Y' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) )  ,TBS.TBSPACE  ,IDX.PCTFREE  ,CAST( 'YES' AS VARCHAR(3) )  ,IDX.NLEVELS  ,IDX.NLEAF  ,IDX.FULLKEYCARD  ,INT(INDCARD/FULLKEYCARD)  ,CLUSTERFACTOR  ,CAST( 'VALID' AS VARCHAR(5) )  ,INDCARD  ,IDX.STATS_TIME  ,CAST( CASE   WHEN IP.TOTAL_PARTS > 0 THEN 'YES'   WHEN TAB.PARTITION_MODE = 'H' THEN 'YES'   WHEN TAB.PARTITION_MODE = 'R' THEN 'YES'   ELSE 'NO'   END AS VARCHAR(3) )  ,CAST( CASE    WHEN (IDX.OWNERTYPE = 'S') OR (IDX.INDNAME LIKE 'SQL%' AND LENGTH(IDX.INDNAME) = 18) THEN 'Y'   ELSE 'N'   END AS VARCHAR(1) )  ,BP.BPNAME FROM SYSCAT.INDEXES IDX LEFT OUTER JOIN INDEXPARTS IP  ON IDX.INDSCHEMA = IP.INDSCHEMA AND IDX.INDNAME = IP.INDNAME  INNER JOIN SYSCAT.TABLES AS TAB ON IDX.TABSCHEMA = TAB.TABSCHEMA AND IDX.TABNAME = TAB.TABNAME  LEFT OUTER JOIN SYSCAT.TABLESPACES AS TBS   INNER JOIN SYSCAT.BUFFERPOOLS AS BP ON TBS.BUFFERPOOLID = BP.BUFFERPOOLID   ON IDX.TBSPACEID = TBS.TBSPACEID;

CREATE VIEW "SYSIBMADM"."ALL_INDEXES" ("OWNER", "INDEX_SCHEMA", "INDEX_NAME", "INDEX_TYPE", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "UNIQUENESS", "COMPRESSION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "STATUS", "NUM_ROWS", "LAST_ANALYZED", "PARTITIONED", "GENERATED", "BUFFER_POOL") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT IC.* FROM SYSIBMADM.DBA_INDEXES IC LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (IC.TABLE_SCHEMA = ATAB.TABSCHEMA AND IC.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR IC.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_IND_COLUMNS" ("INDEX_OWNER", "INDEX_SCHEMA", "INDEX_NAME", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COLUMN_POSITION", "DESCEND") AS
SELECT   IND.OWNER  ,IC.INDSCHEMA  ,IC.INDNAME  ,TAB.OWNER  ,IND.TABSCHEMA  ,IND.TABNAME  ,IC.COLNAME  ,IC.COLSEQ  ,CAST( CASE IC.COLORDER   WHEN 'D' THEN 'Y'   ELSE 'N'   END AS VARCHAR(1) ) FROM SYSCAT.INDEXCOLUSE IC, SYSCAT.INDEXES IND, SYSCAT.TABLES TAB WHERE IC.INDSCHEMA = IND.INDSCHEMA AND IC.INDNAME = IND.INDNAME   AND IND.TABSCHEMA = TAB.TABSCHEMA AND IND.TABNAME = TAB.TABNAME;

CREATE VIEW "SYSIBMADM"."ALL_IND_COLUMNS" ("INDEX_OWNER", "INDEX_SCHEMA", "INDEX_NAME", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COLUMN_POSITION", "DESCEND") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT IC.* FROM SYSIBMADM.DBA_IND_COLUMNS IC LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (IC.TABLE_SCHEMA = ATAB.TABSCHEMA AND IC.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR IC.INDEX_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_IND_PARTITIONS" ("INDEX_OWNER", "INDEX_SCHEMA", "INDEX_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "COMPRESSION", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "NUM_ROWS", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
SELECT  INDEX.OWNER  ,IP.INDSCHEMA  ,IP.INDNAME  ,DP.DATAPARTITIONNAME  ,DP.HIGHVALUE  ,LENGTH(DP.HIGHVALUE)  ,DP.SEQNO  ,TBS.TBSPACE  ,IP.PCTFREE  ,CAST( 'YES' AS VARCHAR(3) )  ,CAST( CASE INDEX.COMPRESSION   WHEN 'Y' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) )  ,IP.NLEVELS  ,IP.NLEAF  ,IP.FULLKEYCARD  ,INT(IP.INDCARD/IP.FULLKEYCARD)  ,IP.CLUSTERFACTOR  ,IP.INDCARD  ,IP.STATS_TIME  ,BP.BPNAME  ,CAST( 'YES' AS VARCHAR(3) ) FROM SYSCAT.INDEXPARTITIONS IP JOIN SYSCAT.DATAPARTITIONS DP ON IP.DATAPARTITIONID = DP.DATAPARTITIONID                                  AND DP.TABSCHEMA = IP.TABSCHEMA                                  AND DP.TABNAME = IP.TABNAME JOIN SYSCAT.INDEXES INDEX ON INDEX.INDSCHEMA = IP.INDSCHEMA AND INDEX.INDNAME = IP.INDNAME JOIN SYSCAT.TABLESPACES TBS ON IP.INDPARTITIONTBSPACEID = TBS.TBSPACEID JOIN SYSCAT.BUFFERPOOLS BP ON BP.BUFFERPOOLID = TBS.BUFFERPOOLID WHERE DP.STATUS != 'I';

CREATE VIEW "SYSIBMADM"."ALL_IND_PARTITIONS" ("INDEX_OWNER", "INDEX_SCHEMA", "INDEX_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "COMPRESSION", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "NUM_ROWS", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT IP.* FROM SYSIBMADM.DBA_IND_PARTITIONS IP JOIN SYSCAT.INDEXES IND ON IP.INDEX_SCHEMA = IND.INDSCHEMA AND IP.INDEX_NAME = IND.INDNAME JOIN ACCESSIBLE_TABLES ATAB ON ATAB.TABSCHEMA = IND.TABSCHEMA AND ATAB.TABNAME = IND.TABNAME WHERE ATAB.ACCESSIBLE = 'Y' OR IP.INDEX_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_OBJECTS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_ID", "DATA_OBJECT_ID", "OBJECT_TYPE", "CREATED", "LAST_DDL_TIME", "TIMESTAMP", "STATUS", "TEMPORARY", "GENERATED") AS
WITH RAUTH AS (SELECT SCHEMA, SPECIFICNAME, MAX(GRANT_TIME) AS GRANT_TIME                FROM SYSCAT.ROUTINEAUTH GROUP BY SCHEMA, SPECIFICNAME),     ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE AND RTAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')),     ACCESSIBLE_SEQUENCES (SEQSCHEMA, SEQNAME, ACCESSIBLE)     AS (SELECT SEQSCHEMA, SEQNAME, 'Y'         FROM SYSCAT.SEQUENCEAUTH SEQAUTH, ALL_IDS IDS         WHERE IDS.ID = SEQAUTH.GRANTEE AND IDS.TYPE = SEQAUTH.GRANTEETYPE AND USAGEAUTH != 'N'),     ACCESSIBLE_MODULES (MODSCHEMA, MODNAME, ACCESSIBLE)     AS (SELECT MODULESCHEMA, MODULENAME, 'Y'         FROM SYSCAT.MODULEAUTH MODAUTH, ALL_IDS IDS         WHERE IDS.ID = MODAUTH.GRANTEE AND IDS.TYPE = MODAUTH.GRANTEETYPE           AND MODAUTH.EXECUTEAUTH != 'N') SELECT DISTINCT OWNER, RT.ROUTINESCHEMA, RT.ROUTINENAME, ROUTINEID, CAST(NULL AS INTEGER),        CAST( CASE         WHEN ROUTINETYPE = 'F' THEN 'FUNCTION'         WHEN ROUTINETYPE = 'P' THEN 'PROCEDURE'         WHEN ROUTINETYPE = 'M' THEN 'METHOD'         ELSE 'UNKNOWN'         END AS VARCHAR(9) ),       CREATE_TIME, GREATEST(ALTER_TIME, GRANT_TIME), CAST(CREATE_TIME AS CHAR(26)), CAST( 'VALID' AS VARCHAR(5) ), CAST( 'N' AS VARCHAR(1) ),        CAST( CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END AS VARCHAR(1) )       FROM RAUTH RA, SYSCAT.ROUTINES RT LEFT OUTER JOIN ACCESSIBLE_ROUTINES ROUTAUTH         ON RT.ROUTINESCHEMA = ROUTAUTH.RTSCHEMA AND RT.SPECIFICNAME = ROUTAUTH.RTSPECIFICNAME       WHERE RT.ROUTINESCHEMA = RA.SCHEMA AND RT.SPECIFICNAME = RA.SPECIFICNAME         AND (ROUTAUTH.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER) UNION ALL SELECT DISTINCT OWNER, IND.INDSCHEMA, IND.INDNAME, IID, TBSPACEID, 'INDEX', CREATE_TIME,        CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE WHEN (OWNERTYPE = 'S') OR (IND.INDNAME LIKE 'SQL%' AND LENGTH(IND.INDNAME) = 18) THEN 'Y'            ELSE 'N' END       FROM SYSCAT.INDEXES IND LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB         ON (IND.TABSCHEMA = ATAB.TABSCHEMA AND IND.TABNAME = ATAB.TABNAME)       WHERE ATAB.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER UNION ALL SELECT DISTINCT OWNER, SEQ.SEQSCHEMA, SEQ.SEQNAME, SEQID, CAST(NULL AS INTEGER),       CASE SEQTYPE WHEN 'A' THEN 'SYNONYM' ELSE 'SEQUENCE' END,       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE WHEN (OWNERTYPE = 'S') OR (SEQ.SEQNAME LIKE 'SQL%' AND LENGTH(SEQ.SEQNAME) = 18) THEN 'Y'            ELSE 'N' END       FROM SYSCAT.SEQUENCES SEQ JOIN ACCESSIBLE_SEQUENCES AUTH          ON AUTH.SEQSCHEMA = SEQ.SEQSCHEMA AND AUTH.SEQNAME = SEQ.SEQNAME        WHERE AUTH.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER UNION ALL SELECT DISTINCT OWNER, TAB.TABSCHEMA, TAB.TABNAME, TABLEID, TBSPACEID,       CASE WHEN (TYPE = 'V' OR TYPE = 'W') THEN 'VIEW'            WHEN TYPE = 'A' THEN 'ALIAS'            WHEN TYPE = 'N' THEN 'NICKNAME'            WHEN TYPE = 'S' THEN 'MATERIALIZED QUERY TABLE'            ELSE 'TABLE' END,       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)),       CASE STATUS WHEN 'X' THEN 'INVALID' ELSE 'VALID' END,       CASE TYPE WHEN 'G' THEN 'Y' ELSE 'N' END,       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.TABLES TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB         ON (TAB.TABSCHEMA = ATAB.TABSCHEMA AND TAB.TABNAME = ATAB.TABNAME)       WHERE ATAB.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER UNION ALL SELECT DISTINCT OWNER, TYPESCHEMA, TYPENAME, TYPEID, CAST(NULL AS INTEGER), 'ABSTRACT DATATYPE',       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.DATATYPES WHERE METATYPE != 'S' UNION ALL SELECT DISTINCT OWNER, TRIGSCHEMA, TRIGNAME, CAST(NULL AS SMALLINT), CAST(NULL AS INTEGER), 'TRIGGER',       CREATE_TIME, CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.TRIGGERS TRIG UNION ALL SELECT DISTINCT OWNER, MODULESCHEMA, MODULENAME, MODULEID, CAST(NULL AS INTEGER),       CASE MODULETYPE WHEN 'A' THEN 'SYNONYM' ELSE 'PACKAGE' END,       CREATE_TIME, CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.MODULES MOD LEFT OUTER JOIN ACCESSIBLE_MODULES AMOD         ON (MOD.MODULESCHEMA = AMOD.MODSCHEMA AND MOD.MODULENAME = AMOD.MODNAME)       WHERE AMOD.ACCESSIBLE = 'Y' OR OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_PART_INDEXES" ("OWNER", "INDEX_SCHEMA", "INDEX_NAME", "TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING") AS
SELECT   IND.OWNER  ,INDPART.INDSCHEMA  ,INDPART.INDNAME  ,INDPART.TABSCHEMA  ,INDPART.TABNAME  ,CAST( CASE   WHEN COUNT(*) > 0 THEN 'RANGE'   WHEN TAB.PARTITION_MODE = 'H' THEN 'HASH'   WHEN TAB.PARTITION_MODE = 'R' THEN 'REPLICATED'   END AS VARCHAR(10) )  ,CAST( CASE   WHEN (COUNT(*) > 0 AND TAB.PARTITION_MODE = 'H') THEN 'HASH'   ELSE 'NONE'   END AS VARCHAR(4) )  ,COUNT(*)  ,IND.COLCOUNT  ,IND.PCTFREE  ,0  ,CAST( 'YES' AS VARCHAR(3) ) FROM SYSCAT.INDEXPARTITIONS INDPART      JOIN SYSCAT.INDEXES IND ON INDPART.INDSCHEMA = IND.INDSCHEMA AND INDPART.INDNAME = IND.INDNAME      JOIN SYSCAT.TABLES TAB ON INDPART.TABSCHEMA = TAB.TABSCHEMA AND INDPART.TABNAME = TAB.TABNAME GROUP BY IND.OWNER, INDPART.INDSCHEMA, INDPART.INDNAME, INDPART.TABSCHEMA, INDPART.TABNAME, TAB.PARTITION_MODE, IND.COLCOUNT, IND.PCTFREE;

CREATE VIEW "SYSIBMADM"."ALL_PART_INDEXES" ("OWNER", "INDEX_SCHEMA", "INDEX_NAME", "TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT IND.* FROM SYSIBMADM.DBA_PART_INDEXES IND JOIN ACCESSIBLE_TABLES ATAB ON ATAB.TABSCHEMA = IND.TABLE_SCHEMA                           AND ATAB.TABNAME = IND.TABLE_NAME WHERE ATAB.ACCESSIBLE = 'Y' OR IND.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_PART_KEY_COLUMNS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_TYPE", "COLUMN_NAME", "COLUMN_POSITION") AS
SELECT TAB.OWNER, COL.TABSCHEMA, COL.TABNAME, CAST( 'TABLE' AS VARCHAR(5) ), COL.COLNAME, COL.PARTKEYSEQ   FROM SYSCAT.COLUMNS COL, SYSCAT.TABLES TAB   WHERE COL.TABSCHEMA = TAB.TABSCHEMA AND COL.TABNAME = TAB.TABNAME AND COL.PARTKEYSEQ > 0 UNION  SELECT TAB.OWNER, DE.TABSCHEMA, DE.TABNAME, 'TABLE', CAST( DE.DATAPARTITIONEXPRESSION AS VARCHAR(128) ), DE.DATAPARTITIONKEYSEQ   FROM SYSCAT.DATAPARTITIONEXPRESSION DE, SYSCAT.TABLES TAB   WHERE DE.TABSCHEMA = TAB.TABSCHEMA AND DE.TABNAME = TAB.TABNAME AND DE.DATAPARTITIONKEYSEQ > 0;

CREATE VIEW "SYSIBMADM"."ALL_PART_KEY_COLUMNS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_TYPE", "COLUMN_NAME", "COLUMN_POSITION") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_PART_KEY_COLUMNS TAB JOIN ACCESSIBLE_TABLES ATAB ON ATAB.TABSCHEMA = TAB.OBJECT_SCHEMA                           AND ATAB.TABNAME = TAB.OBJECT_NAME WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_PART_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING", "DEF_COMPRESSION") AS
WITH DATAPARTS (TABSCHEMA, TABNAME, TOTAL_PARTS, PARTKEY_COUNT)       AS ( SELECT DP.TABSCHEMA, DP.TABNAME, COUNT(*), MAX(DE.DATAPARTITIONKEYSEQ)         FROM SYSCAT.DATAPARTITIONS DP, SYSCAT.DATAPARTITIONEXPRESSION DE         WHERE DP.TABSCHEMA = DE.TABSCHEMA AND DP.TABNAME = DE.TABNAME        GROUP BY DP.TABSCHEMA, DP.TABNAME),     PARTKEYSEQ (TABSCHEMA, TABNAME, PARTKEY_COUNT)      AS ( SELECT TABSCHEMA, TABNAME, MAX(PARTKEYSEQ) FROM SYSCAT.COLUMNS         GROUP BY TABSCHEMA, TABNAME)   SELECT   TAB.OWNER  ,TAB.TABSCHEMA  ,TAB.TABNAME  ,CAST( CASE   WHEN DP.TOTAL_PARTS > 0 THEN 'RANGE'   WHEN PARTITION_MODE = 'H' THEN 'HASH'   WHEN PARTITION_MODE = 'R' THEN 'REPLICATED'   END AS VARCHAR(10) )  ,CAST( CASE    WHEN (DP.TOTAL_PARTS > 0 AND PARTITION_MODE = 'H') THEN 'HASH'   ELSE 'NONE'   END AS VARCHAR(4) )  ,DP.TOTAL_PARTS  ,CASE   WHEN DP.TOTAL_PARTS > 0 THEN DP.PARTKEY_COUNT   WHEN PARTITION_MODE = 'H' THEN PK.PARTKEY_COUNT   END  ,PCTFREE  ,0  ,CAST( CASE TAB.LOGGED   WHEN 'N' THEN 'NO'   ELSE 'YES'   END AS VARCHAR(3) )  ,CAST( CASE COMPRESSION   WHEN 'B' THEN 'ENABLED'   WHEN 'R' THEN 'ENABLED'   WHEN 'V' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) ) FROM SYSCAT.TABLES TAB LEFT JOIN DATAPARTS DP ON TAB.TABSCHEMA = DP.TABSCHEMA AND TAB.TABNAME = DP.TABNAME JOIN PARTKEYSEQ PK ON TAB.TABSCHEMA = PK.TABSCHEMA AND TAB.TABNAME = PK.TABNAME WHERE TAB.PARTITION_MODE IN ('H','R') OR (DP.TOTAL_PARTS IS NOT NULL AND DP.TOTAL_PARTS > 0);

CREATE VIEW "SYSIBMADM"."ALL_PART_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING", "DEF_COMPRESSION") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_PART_TABLES TAB JOIN ACCESSIBLE_TABLES ATAB ON ATAB.TABSCHEMA = TAB.TABLE_SCHEMA                           AND ATAB.TABNAME = TAB.TABLE_NAME WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_PROCEDURES" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "PROCEDURE_SCHEMA", "PROCEDURE_NAME", "PROCEDURE_SPECIFIC_NAME", "AGGREGATE", "PARALLEL") AS
SELECT   ROUT.OWNER  ,CASE WHEN MOD.MODULESCHEMA IS NULL THEN ROUTINESCHEMA ELSE MOD.MODULESCHEMA END  ,CASE WHEN MOD.MODULENAME IS NULL THEN ROUTINENAME ELSE MOD.MODULENAME END  ,ROUTINESCHEMA  ,ROUTINENAME  ,SPECIFICNAME  ,CAST( CASE FUNCTIONTYPE WHEN 'C' THEN 'YES' ELSE 'NO' END AS VARCHAR(3) )  ,CAST( CASE PARALLEL WHEN 'Y' THEN 'YES' ELSE 'NO' END AS VARCHAR(3) ) FROM SYSCAT.ROUTINES ROUT LEFT OUTER JOIN SYSCAT.MODULES MOD  ON ROUT.ROUTINEMODULEID = MOD.MODULEID;

CREATE VIEW "SYSIBMADM"."ALL_PROCEDURES" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "PROCEDURE_SCHEMA", "PROCEDURE_NAME", "PROCEDURE_SPECIFIC_NAME", "AGGREGATE", "PARALLEL") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE AND RTAUTH.EXECUTEAUTH != 'N') SELECT PROC.* FROM SYSIBMADM.DBA_PROCEDURES PROC, SYSCAT.ROUTINES ROUT     LEFT OUTER JOIN ACCESSIBLE_ROUTINES AUTH     ON ROUT.ROUTINESCHEMA = AUTH.RTSCHEMA AND ROUT.SPECIFICNAME = AUTH.RTSPECIFICNAME WHERE PROC.PROCEDURE_SCHEMA = ROUT.ROUTINESCHEMA AND PROC.PROCEDURE_NAME = ROUT.ROUTINENAME AND (AUTH.ACCESSIBLE = 'Y' OR PROC.OWNER = CURRENT USER);

CREATE VIEW "SYSIBMADM"."DBA_SEQUENCES" ("SEQUENCE_OWNER", "SEQUENCE_SCHEMA", "SEQUENCE_NAME", "MIN_VALUE", "MAX_VALUE", "INCREMENT_BY", "CYCLE_FLAG", "ORDER_FLAG", "CACHE_SIZE", "LAST_NUMBER") AS
SELECT   OWNER  ,SEQSCHEMA  ,SEQNAME  ,MINVALUE  ,MAXVALUE  ,INCREMENT  ,CYCLE  ,ORDER  ,CACHE  ,CAST( NEXTCACHEFIRSTVALUE - INCREMENT AS DECFLOAT ) FROM SYSCAT.SEQUENCES WHERE SEQTYPE != 'A';

CREATE VIEW "SYSIBMADM"."ALL_SEQUENCES" ("SEQUENCE_OWNER", "SEQUENCE_SCHEMA", "SEQUENCE_NAME", "MIN_VALUE", "MAX_VALUE", "INCREMENT_BY", "CYCLE_FLAG", "ORDER_FLAG", "CACHE_SIZE", "LAST_NUMBER") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_SEQUENCES (SEQSCHEMA, SEQNAME, ACCESSIBLE)     AS (SELECT SEQSCHEMA, SEQNAME, 'Y'         FROM SYSCAT.SEQUENCEAUTH SEQAUTH, ALL_IDS IDS         WHERE IDS.ID = SEQAUTH.GRANTEE AND IDS.TYPE = SEQAUTH.GRANTEETYPE AND USAGEAUTH != 'N') SELECT SEQ.* FROM SYSIBMADM.DBA_SEQUENCES SEQ JOIN ACCESSIBLE_SEQUENCES AUTH ON AUTH.SEQSCHEMA = SEQ.SEQUENCE_SCHEMA                              AND AUTH.SEQNAME = SEQ.SEQUENCE_NAME WHERE AUTH.ACCESSIBLE = 'Y' OR SEQ.SEQUENCE_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_SOURCE" ("OWNER", "SCHEMA", "NAME", "SPECIFICNAME", "TYPE", "TEXT") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_ROUTINES (RTSCHEMA, RTSPECIFICNAME, ACCESSIBLE)     AS (SELECT DISTINCT SCHEMA, SPECIFICNAME, 'Y'         FROM SYSCAT.ROUTINEAUTH RTAUTH, ALL_IDS IDS         WHERE IDS.ID = RTAUTH.GRANTEE AND IDS.TYPE = RTAUTH.GRANTEETYPE            AND RTAUTH.EXECUTEAUTH != 'N'),     ACCESSIBLE_MODULES (MODSCHEMA, MODNAME, ACCESSIBLE)     AS (SELECT DISTINCT MODULESCHEMA, MODULENAME, 'Y'         FROM SYSCAT.MODULEAUTH MODAUTH, ALL_IDS IDS         WHERE IDS.ID = MODAUTH.GRANTEE AND IDS.TYPE = MODAUTH.GRANTEETYPE           AND MODAUTH.EXECUTEAUTH != 'N') SELECT   ROUT.OWNER  ,ROUT.ROUTINESCHEMA  ,ROUT.ROUTINENAME  ,ROUT.SPECIFICNAME  ,CAST( CASE     WHEN ROUTINETYPE = 'P' THEN 'PROCEDURE'     WHEN ROUTINETYPE = 'F' THEN 'FUNCTION'     WHEN ROUTINETYPE = 'M' THEN 'METHOD'     ELSE 'UNKNOWN'   END AS VARCHAR(9) )  ,ROUT.TEXT FROM SYSCAT.ROUTINES ROUT LEFT OUTER JOIN ACCESSIBLE_ROUTINES AUTH  ON ROUT.ROUTINESCHEMA = AUTH.RTSCHEMA AND ROUT.SPECIFICNAME = AUTH.RTSPECIFICNAME WHERE AUTH.ACCESSIBLE = 'Y' OR ROUT.OWNER = CURRENT USER UNION ALL SELECT   OWNER  ,TRIGSCHEMA  ,TRIGNAME  ,CAST( NULL AS VARCHAR(128) )  ,'TRIGGER'  ,TEXT FROM SYSCAT.TRIGGERS UNION ALL SELECT   OWNER  ,MODULESCHEMA  ,MODULENAME  ,CAST( NULL AS VARCHAR(128) )  ,'PACKAGE'  ,SOURCEHEADER FROM SYSIBM.SYSMODULES MOD LEFT OUTER JOIN ACCESSIBLE_MODULES AUTH   ON MOD.MODULESCHEMA = AUTH.MODSCHEMA AND MOD.MODULENAME = AUTH.MODNAME WHERE AUTH.ACCESSIBLE = 'Y' OR MOD.OWNER = CURRENT USER UNION ALL SELECT   OWNER  ,MODULESCHEMA  ,MODULENAME  ,CAST( NULL AS VARCHAR(128) )  ,'PACKAGE BODY'  ,SOURCEBODY FROM SYSIBM.SYSMODULES MOD LEFT OUTER JOIN ACCESSIBLE_MODULES AUTH   ON MOD.MODULESCHEMA = AUTH.MODSCHEMA AND MOD.MODULENAME = AUTH.MODNAME WHERE (AUTH.ACCESSIBLE = 'Y' OR MOD.OWNER = CURRENT USER) AND LENGTH(MOD.SOURCEBODY) > 1;

CREATE VIEW "SYSIBMADM"."ALL_SYNONYMS" ("OWNER", "SYNONYM_SCHEMA", "SYNONYM_NAME", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')),     ACCESSIBLE_SEQUENCES (SEQSCHEMA, SEQNAME, ACCESSIBLE)     AS (SELECT SEQSCHEMA, SEQNAME, 'Y'         FROM SYSCAT.SEQUENCEAUTH SEQAUTH, ALL_IDS IDS         WHERE IDS.ID = SEQAUTH.GRANTEE AND IDS.TYPE = SEQAUTH.GRANTEETYPE AND USAGEAUTH != 'N'),     ACCESSIBLE_MODULES (MODULESCHEMA, MODULENAME, ACCESSIBLE)     AS (SELECT MODULESCHEMA, MODULENAME, 'Y'         FROM SYSCAT.MODULEAUTH MODAUTH, ALL_IDS IDS         WHERE IDS.ID = MODAUTH.GRANTEE AND IDS.TYPE = MODAUTH.GRANTEETYPE AND EXECUTEAUTH != 'N') SELECT   TAB.OWNER  ,TAB.TABSCHEMA  ,TAB.TABNAME  ,REF.OWNER  ,TAB.BASE_TABSCHEMA  ,TAB.BASE_TABNAME FROM SYSCAT.TABLES TAB LEFT OUTER JOIN  SYSCAT.TABLES REF ON TAB.BASE_TABSCHEMA = REF.TABSCHEMA AND TAB.BASE_TABNAME = REF.TABNAME  LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB  ON (TAB.BASE_TABSCHEMA = ATAB.TABSCHEMA AND TAB.BASE_TABNAME = ATAB.TABNAME) WHERE TAB.TYPE = 'A' AND (ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER) UNION ALL SELECT   SEQ.OWNER  ,SEQ.SEQSCHEMA  ,SEQ.SEQNAME  ,REF.OWNER  ,SEQ.BASE_SEQSCHEMA  ,SEQ.BASE_SEQNAME FROM SYSCAT.SEQUENCES SEQ LEFT OUTER JOIN  SYSCAT.SEQUENCES REF ON SEQ.BASE_SEQSCHEMA = REF.SEQSCHEMA AND SEQ.BASE_SEQNAME = REF.SEQNAME  LEFT OUTER JOIN ACCESSIBLE_SEQUENCES ASEQ  ON (SEQ.SEQSCHEMA = ASEQ.SEQSCHEMA AND SEQ.SEQNAME = ASEQ.SEQNAME) WHERE SEQ.SEQTYPE = 'A' AND (ASEQ.ACCESSIBLE = 'Y' OR SEQ.OWNER = CURRENT USER) UNION ALL SELECT   MOD.OWNER  ,MOD.MODULESCHEMA  ,MOD.MODULENAME  ,REF.OWNER  ,MOD.BASE_MODULESCHEMA  ,MOD.BASE_MODULENAME FROM SYSCAT.MODULES MOD LEFT OUTER JOIN  SYSCAT.MODULES REF ON MOD.BASE_MODULESCHEMA = REF.MODULESCHEMA                        AND MOD.MODULENAME = REF.MODULENAME  LEFT OUTER JOIN ACCESSIBLE_MODULES AMOD   ON (MOD.MODULESCHEMA = AMOD.MODULESCHEMA AND MOD.MODULENAME = AMOD.MODULENAME)  WHERE MOD.MODULETYPE = 'A' AND (AMOD.ACCESSIBLE = 'Y' OR MOD.OWNER = CURRENT USER);

CREATE VIEW "SYSIBMADM"."DBA_TAB_COLUMNS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_TYPE_OWNER", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "NULLABLE", "COLUMN_ID", "DEFAULT_LENGTH", "DATA_DEFAULT", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "CHAR_COL_DECL_LENGTH", "GLOBAL_STATS", "AVG_COL_LEN", "CHAR_LENGTH", "CHAR_USED") AS
SELECT   T.OWNER  ,C.TABSCHEMA  ,C.TABNAME  ,C.COLNAME  ,C.TYPENAME  ,D.OWNER  ,CASE C.TYPENAME    WHEN 'GRAPHIC' THEN C.LENGTH*2    WHEN 'VARGRAPHIC' THEN C.LENGTH*2   WHEN 'LONG VARGRAPHIC' THEN C.LENGTH*2   WHEN 'DBCLOB' THEN C.LENGTH*2   ELSE C.LENGTH   END  ,CASE C.TYPENAME WHEN 'DECIMAL' THEN C.LENGTH END  ,C.SCALE  ,C.NULLS  ,CAST(C.COLNO + 1 AS SMALLINT)  ,LENGTH(C.DEFAULT)  ,C.DEFAULT  ,C.COLCARD  ,C.NUMNULLS  ,T.STATS_TIME  ,CASE C.TYPENAME    WHEN 'CHAR' THEN C.LENGTH    WHEN 'VARCHAR' THEN C.LENGTH   WHEN 'LONG VARCHAR' THEN C.LENGTH   END  ,CAST( 'YES' AS VARCHAR(3) )  ,C.AVGCOLLEN  ,C.LENGTH  ,CAST( CASE C.TYPENAME   WHEN 'GRAPHIC' THEN 'C'   WHEN 'VARGRAPHIC' THEN 'C'   WHEN 'LONG VARGRAPHIC' THEN 'C'   WHEN 'DBCLOB' THEN 'C'   ELSE 'B'   END AS VARCHAR(1) ) FROM SYSCAT.COLUMNS C, SYSCAT.TABLES T, SYSCAT.DATATYPES D WHERE C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME=T.TABNAME AND T.TYPE NOT IN ('V','W')  AND C.TYPESCHEMA = D.TYPESCHEMA AND C.TYPENAME = D.TYPENAME;

CREATE VIEW "SYSIBMADM"."ALL_TAB_COLUMNS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_TYPE_OWNER", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "NULLABLE", "COLUMN_ID", "DEFAULT_LENGTH", "DATA_DEFAULT", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "CHAR_COL_DECL_LENGTH", "GLOBAL_STATS", "AVG_COL_LEN", "CHAR_LENGTH", "CHAR_USED") AS
WITH ALL_IDS (ID, TYPE)     AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'          OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_TAB_COLUMNS TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (TAB.TABLE_SCHEMA = ATAB.TABSCHEMA AND TAB.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_TAB_COL_STATISTICS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "GLOBAL_STATS", "AVG_COL_LEN") AS
SELECT   T.OWNER  ,C.TABSCHEMA  ,C.TABNAME  ,C.COLNAME  ,C.COLCARD  ,C.NUMNULLS  ,T.STATS_TIME  ,CAST( 'YES' AS VARCHAR(3) )  ,C.AVGCOLLEN FROM SYSCAT.COLUMNS C, SYSCAT.TABLES T WHERE C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME=T.TABNAME AND T.TYPE NOT IN ('V','W');

CREATE VIEW "SYSIBMADM"."ALL_TAB_COL_STATISTICS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "GLOBAL_STATS", "AVG_COL_LEN") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_TAB_COL_STATISTICS TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (TAB.TABLE_SCHEMA = ATAB.TABSCHEMA AND TAB.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_TAB_COMMENTS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "COMMENTS") AS
SELECT   TAB.OWNER  ,TABSCHEMA  ,TABNAME  ,CAST( CASE TYPE   WHEN 'A' THEN 'SYNONYM'   WHEN 'N' THEN 'NICKNAME'   WHEN 'V' THEN 'VIEW'   WHEN 'W' THEN 'VIEW'   ELSE 'TABLE'   END AS VARCHAR(8) )  ,REMARKS FROM SYSCAT.TABLES TAB;

CREATE VIEW "SYSIBMADM"."ALL_TAB_COMMENTS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "COMMENTS") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_TAB_COMMENTS TAB LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (TAB.TABLE_SCHEMA = ATAB.TABSCHEMA AND TAB.TABLE_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_TAB_PARTITIONS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "COMPRESSION", "AVG_ROW_LEN", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
SELECT   TAB.OWNER  ,DP.TABSCHEMA  ,DP.TABNAME  ,DP.DATAPARTITIONNAME  ,DP.HIGHVALUE  ,LENGTH(DP.HIGHVALUE)  ,DP.SEQNO  ,TBS.TBSPACE  ,TAB.PCTFREE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,0  ,CAST( CASE TAB.LOGGED   WHEN 'N' THEN 'NO'   ELSE 'YES'   END AS VARCHAR(3) )  ,CAST( CASE TAB.COMPRESSION   WHEN 'B' THEN 'ENABLED'   WHEN 'R' THEN 'ENABLED'   WHEN 'V' THEN 'ENABLED'   ELSE 'DISABLED'   END AS VARCHAR(8) )  ,TAB.AVGROWSIZE  ,TAB.STATS_TIME  ,BP.BPNAME  ,CAST( 'YES' AS VARCHAR(3) ) FROM SYSCAT.DATAPARTITIONS DP, SYSCAT.DATAPARTITIONEXPRESSION DE,     SYSCAT.TABLES TAB, SYSCAT.TABLESPACES TBS LEFT JOIN SYSCAT.BUFFERPOOLS BP ON BP.BUFFERPOOLID = TBS.BUFFERPOOLID WHERE DP.TABSCHEMA = DE.TABSCHEMA AND DP.TABNAME = DE.TABNAME AND DP.STATUS != 'I'   AND DP.TABSCHEMA = TAB.TABSCHEMA AND DP.TABNAME = TAB.TABNAME   AND DP.TBSPACEID = TBS.TBSPACEID;

CREATE VIEW "SYSIBMADM"."ALL_TAB_PARTITIONS" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "COMPRESSION", "AVG_ROW_LEN", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT TAB.* FROM SYSIBMADM.DBA_TAB_PARTITIONS TAB JOIN ACCESSIBLE_TABLES ATAB ON ATAB.TABSCHEMA = TAB.TABLE_SCHEMA                           AND ATAB.TABNAME = TAB.TABLE_NAME WHERE ATAB.ACCESSIBLE = 'Y' OR TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."DBA_TAB_PRIVS" ("GRANTEE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
WITH TABVIEW_PRIVS(GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, CONTROLAUTH, ALTERAUTH,                    DELETEAUTH, INDEXAUTH, INSERTAUTH, SELECTAUTH, REFAUTH, UPDATEAUTH)        AS ( SELECT A.GRANTEE, B.OWNER, A.TABSCHEMA, A.TABNAME, A.GRANTOR, A.CONTROLAUTH, A.ALTERAUTH,                     A.DELETEAUTH, A.INDEXAUTH, A.INSERTAUTH, A.SELECTAUTH, A.REFAUTH, A.UPDATEAUTH             FROM SYSCAT.TABAUTH A, SYSCAT.TABLES B             WHERE A.TABSCHEMA = B.TABSCHEMA AND A.TABNAME = B.TABNAME),        SEQ_PRIVS(GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, ALTERAUTH, USAGEAUTH)        AS ( SELECT SEQAUTH.GRANTEE, SEQ.OWNER, SEQAUTH.SEQSCHEMA, SEQAUTH.SEQNAME,                    SEQAUTH.GRANTOR, SEQAUTH.ALTERAUTH, SEQAUTH.USAGEAUTH             FROM SYSCAT.SEQUENCEAUTH SEQAUTH, SYSCAT.SEQUENCES SEQ             WHERE SEQAUTH.SEQSCHEMA = SEQ.SEQSCHEMA AND SEQAUTH.SEQNAME = SEQ.SEQNAME),     PKG_PRIVS(GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, CONTROLAUTH, BINDAUTH, EXECUTEAUTH)        AS ( SELECT PKGAUTH.GRANTEE, PKG.OWNER, PKGAUTH.PKGSCHEMA, PKGAUTH.PKGNAME, PKGAUTH.GRANTOR,                     PKGAUTH.CONTROLAUTH, PKGAUTH.BINDAUTH, PKGAUTH.EXECUTEAUTH             FROM SYSCAT.PACKAGEAUTH PKGAUTH, SYSCAT.PACKAGES PKG             WHERE PKGAUTH.PKGSCHEMA = PKG.PKGSCHEMA AND PKGAUTH.PKGNAME = PKG.PKGNAME),     FUNCPROC_PRIVS(GRANTEE, OWNER, ROUTSCHEMA, ROUTNAME, GRANTOR, EXECUTEAUTH)        AS ( SELECT AUTH.GRANTEE, RTS.OWNER, RTS.ROUTINESCHEMA, RTS.ROUTINENAME, AUTH.GRANTOR, AUTH.EXECUTEAUTH             FROM SYSCAT.ROUTINEAUTH AUTH, SYSCAT.ROUTINES RTS             WHERE AUTH.SPECIFICNAME IS NOT NULL AND AUTH.SCHEMA = RTS.ROUTINESCHEMA AND                   AUTH.SPECIFICNAME = RTS.SPECIFICNAME) SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, CAST( 'CONTROL' AS VARCHAR(7) ), CAST( 'NO' AS VARCHAR(3) ) FROM        TABVIEW_PRIVS WHERE CONTROLAUTH = 'Y' UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'ALTER', CASE ALTERAUTH WHEN 'G' THEN 'YES' ELSE 'N' END   FROM TABVIEW_PRIVS WHERE ALTERAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'DELETE', CASE DELETEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE DELETEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'INDEX', CASE INDEXAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE INDEXAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'INSERT', CASE INSERTAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE INSERTAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'REFERENCE', CASE REFAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE REFAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'SELECT', CASE SELECTAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE SELECTAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'UPDATE', CASE UPDATEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE UPDATEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, 'ALTER', CASE ALTERAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM SEQ_PRIVS WHERE ALTERAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, 'USAGE', CASE USAGEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM SEQ_PRIVS WHERE USAGEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'CONTROL', 'NO' FROM PKG_PRIVS WHERE CONTROLAUTH = 'Y' UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'BIND', CASE BINDAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM PKG_PRIVS WHERE BINDAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM PKG_PRIVS WHERE EXECUTEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, ROUTSCHEMA, ROUTNAME, GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM FUNCPROC_PRIVS WHERE EXECUTEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, '', SCHEMA, CASE ROUTINETYPE WHEN 'P' THEN 'ALL PROCEDURES' WHEN 'F' THEN 'ALL FUNCTIONS' END,   GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END FROM SYSCAT.ROUTINEAUTH   WHERE SPECIFICNAME IS NULL AND ROUTINETYPE IN ('P','F');

CREATE VIEW "SYSIBMADM"."ALL_TAB_PRIVS" ("GRANTEE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT * FROM SYSIBMADM.DBA_TAB_PRIVS WHERE GRANTEE = CURRENT USER OR GRANTOR = CURRENT USER OR OWNER = CURRENT USER   OR GRANTEE = 'PUBLIC';

CREATE VIEW "SYSIBMADM"."ALL_TAB_PRIVS_MADE" ("GRANTEE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT   GRANTEE  ,OWNER  ,TABLE_SCHEMA  ,TABLE_NAME  ,GRANTOR  ,PRIVILEGE  ,GRANTABLE FROM SYSIBMADM.DBA_TAB_PRIVS PRIV WHERE PRIV.OWNER = CURRENT USER OR PRIV.GRANTOR = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_TAB_PRIVS_RECD" ("GRANTEE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT    GRANTEE  ,OWNER  ,TABLE_SCHEMA  ,TABLE_NAME  ,GRANTOR  ,PRIVILEGE  ,GRANTABLE FROM SYSIBMADM.DBA_TAB_PRIVS PRIV WHERE PRIV.GRANTEE = CURRENT USER OR PRIV.GRANTEE = 'PUBLIC';

CREATE VIEW "SYSIBMADM"."DBA_TRIGGERS" ("OWNER", "TRIGGER_SCHEMA", "TRIGGER_NAME", "TRIGGER_TYPE", "TRIGGERING_EVENT", "TABLE_OWNER", "BASE_OBJECT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "STATUS", "TRIGGER_BODY") AS
SELECT   TRIG.OWNER  ,TRIGSCHEMA  ,TRIGNAME  ,CAST( CASE TRIGTIME     WHEN 'A' THEN       CASE GRANULARITY         WHEN 'R' THEN 'AFTER ROW'         WHEN 'S' THEN 'AFTER STATEMENT'         ELSE 'UNKNOWN'       END     WHEN 'B' THEN       CASE GRANULARITY         WHEN 'R' THEN 'BEFORE ROW'         WHEN 'S' THEN 'AFTER STATEMENT'         ELSE 'UNKNOWN'       END     WHEN 'I' THEN 'INSTEAD OF'     ELSE 'UNKNOWN'   END AS VARCHAR(15) )  ,CAST( CASE TRIGEVENT     WHEN 'D' THEN 'DML'     WHEN 'I' THEN 'DML'     WHEN 'U' THEN 'DML'     ELSE 'UNKNOWN'   END AS VARCHAR(7) )  ,TAB.OWNER  ,CAST( CASE TAB.TYPE     WHEN 'V' THEN 'VIEW'     WHEN 'W' THEN 'VIEW'     WHEN 'A' THEN 'ALIAS'     ELSE 'TABLE'   END AS VARCHAR(5) )  ,TRIG.TABSCHEMA  ,TRIG.TABNAME  ,CAST( CASE VALID     WHEN 'Y' THEN 'ENABLED'     ELSE 'DISABLED'   END AS VARCHAR(8) )  ,TEXT FROM SYSCAT.TRIGGERS TRIG JOIN SYSCAT.TABLES TAB ON TRIG.TABSCHEMA = TAB.TABSCHEMA                      AND TRIG.TABNAME = TAB.TABNAME;

CREATE VIEW "SYSIBMADM"."DBA_VIEWS" ("OWNER", "VIEW_SCHEMA", "VIEW_NAME", "TEXT_LENGTH", "TEXT") AS
SELECT   V.OWNER  ,V.VIEWSCHEMA  ,V.VIEWNAME  ,LENGTH(V.TEXT)  ,V.TEXT FROM SYSCAT.VIEWS V;

CREATE VIEW "SYSIBMADM"."ALL_VIEWS" ("OWNER", "VIEW_SCHEMA", "VIEW_NAME", "TEXT_LENGTH", "TEXT") AS
WITH ALL_IDS (ID, TYPE)      AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'           OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT VIEW.* FROM SYSIBMADM.DBA_VIEWS VIEW LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (VIEW.VIEW_SCHEMA = ATAB.TABSCHEMA AND VIEW.VIEW_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR VIEW.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."ALL_TRIGGERS" ("OWNER", "TRIGGER_SCHEMA", "TRIGGER_NAME", "TRIGGER_TYPE", "TRIGGERING_EVENT", "TABLE_OWNER", "BASE_OBJECT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "STATUS", "TRIGGER_BODY") AS
SELECT TRIG.* FROM SYSIBMADM.DBA_TRIGGERS TRIG JOIN SYSIBMADM.ALL_TABLES TAB ON TAB.TABLE_SCHEMA = TRIG.TABLE_SCHEMA AND TAB.TABLE_NAME = TRIG.TABLE_NAME UNION ALL SELECT TRIG.* FROM SYSIBMADM.DBA_TRIGGERS TRIG JOIN SYSIBMADM.ALL_VIEWS VIEW ON VIEW.VIEW_SCHEMA = TRIG.TABLE_SCHEMA AND VIEW.VIEW_NAME = TRIG.TABLE_NAME;

CREATE VIEW "SYSIBMADM"."DBA_VIEW_COLUMNS" ("OWNER", "VIEW_SCHEMA", "VIEW_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "COLUMN_ID", "NULLABLE", "DATA_DEFAULT") AS
SELECT   T.OWNER  ,C.TABSCHEMA  ,C.TABNAME  ,C.COLNAME  ,C.TYPENAME  ,C.LENGTH  ,CASE C.TYPENAME WHEN 'DECIMAL' THEN C.LENGTH END  ,C.SCALE  ,CAST(C.COLNO + 1 AS SMALLINT)  ,C.NULLS  ,C.DEFAULT FROM SYSCAT.COLUMNS C, SYSCAT.TABLES T WHERE C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME=T.TABNAME AND T.TYPE IN ('V','W');

CREATE VIEW "SYSIBMADM"."ALL_VIEW_COLUMNS" ("OWNER", "VIEW_SCHEMA", "VIEW_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "COLUMN_ID", "NULLABLE", "DATA_DEFAULT") AS
WITH ALL_IDS (ID, TYPE)     AS (SELECT CURRENT USER, 'U' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT 'PUBLIC','G' FROM SYSIBM.SYSDUMMY1         UNION ALL         SELECT G.GROUP, 'G' FROM TABLE(AUTH_LIST_GROUPS_FOR_AUTHID(CURRENT USER)) AS G         UNION ALL         SELECT R.ROLENAME, 'R' FROM TABLE(AUTH_LIST_ROLES_FOR_AUTHID(CURRENT USER, 'U')) AS R),     ACCESSIBLE_TABLES (TABSCHEMA, TABNAME, ACCESSIBLE)     AS (SELECT TABSCHEMA, TABNAME, 'Y'         FROM SYSCAT.TABAUTH TABAUTH, ALL_IDS IDS         WHERE IDS.ID = TABAUTH.GRANTEE AND IDS.TYPE = TABAUTH.GRANTEETYPE AND         (TABAUTH.DELETEAUTH != 'N' OR TABAUTH.INSERTAUTH != 'N'          OR TABAUTH.SELECTAUTH != 'N' OR UPDATEAUTH != 'N')) SELECT VIEW.* FROM SYSIBMADM.DBA_VIEW_COLUMNS VIEW LEFT OUTER JOIN ACCESSIBLE_TABLES ATAB ON (VIEW.VIEW_SCHEMA = ATAB.TABSCHEMA AND VIEW.VIEW_NAME = ATAB.TABNAME) WHERE ATAB.ACCESSIBLE = 'Y' OR VIEW.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."SNAPAPPL_INFO" ("SNAPSHOT_TIMESTAMP", "AGENT_ID", "APPL_STATUS", "CODEPAGE_ID", "NUM_ASSOC_AGENTS", "COORD_NODE_NUM", "AUTHORITY_LVL", "CLIENT_PID", "COORD_AGENT_PID", "STATUS_CHANGE_TIME", "CLIENT_PLATFORM", "CLIENT_PROTOCOL", "TERRITORY_CODE", "APPL_NAME", "APPL_ID", "SEQUENCE_NO", "PRIMARY_AUTH_ID", "SESSION_AUTH_ID", "CLIENT_NNAME", "CLIENT_PRDID", "INPUT_DB_ALIAS", "CLIENT_DB_ALIAS", "DB_NAME", "DB_PATH", "EXECUTION_ID", "CORR_TOKEN", "TPMON_CLIENT_USERID", "TPMON_CLIENT_WKSTN", "TPMON_CLIENT_APP", "TPMON_ACC_STR", "DBPARTITIONNUM", "WORKLOAD_ID", "IS_SYSTEM_APPL") AS
SELECT  snapshot_timestamp, agent_id, appl_status, codepage_id, num_assoc_agents,  coord_node_num, authority_lvl, client_pid, coord_agent_pid,status_change_time,  client_platform, client_protocol, territory_code, appl_name, appl_id, sequence_no,  primary_auth_id, session_auth_id, client_nname, client_prdid, input_db_alias,  client_db_alias, db_name, db_path, execution_id, corr_token, tpmon_client_userid,  tpmon_client_wkstn, tpmon_client_app, tpmon_acc_str, dbpartitionnum, workload_id, is_system_appl FROM TABLE(SYSPROC.SNAP_GET_APPL_INFO_V95(' ')) as T;

CREATE VIEW "SYSIBMADM"."APPLICATIONS" ("SNAPSHOT_TIMESTAMP", "CLIENT_DB_ALIAS", "DB_NAME", "AGENT_ID", "APPL_NAME", "AUTHID", "APPL_ID", "APPL_STATUS", "STATUS_CHANGE_TIME", "SEQUENCE_NO", "CLIENT_PRDID", "CLIENT_PID", "CLIENT_PLATFORM", "CLIENT_PROTOCOL", "CLIENT_NNAME", "COORD_NODE_NUM", "COORD_AGENT_PID", "NUM_ASSOC_AGENTS", "TPMON_CLIENT_USERID", "TPMON_CLIENT_WKSTN", "TPMON_CLIENT_APP", "TPMON_ACC_STR", "DBPARTITIONNUM") AS
SELECT  SNAPSHOT_TIMESTAMP, CLIENT_DB_ALIAS, DB_NAME, AGENT_ID, APPL_NAME, PRIMARY_AUTH_ID, APPL_ID, APPL_STATUS, STATUS_CHANGE_TIME, SEQUENCE_NO, CLIENT_PRDID, CLIENT_PID, CLIENT_PLATFORM, CLIENT_PROTOCOL, CLIENT_NNAME,  COORD_NODE_NUM, COORD_AGENT_PID, NUM_ASSOC_AGENTS, TPMON_CLIENT_USERID, TPMON_CLIENT_WKSTN, TPMON_CLIENT_APP, TPMON_ACC_STR, DBPARTITIONNUM FROM SYSIBMADM.SNAPAPPL_INFO;

CREATE VIEW "SYSIBMADM"."SNAPAPPL" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "UOW_LOG_SPACE_USED", "ROWS_READ", "ROWS_WRITTEN", "INACT_STMTHIST_SZ", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_DATA_WRITES", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_INDEX_WRITES", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_TEMP_XDA_L_READS", "POOL_TEMP_XDA_P_READS", "POOL_XDA_L_READS", "POOL_XDA_P_READS", "POOL_XDA_WRITES", "POOL_READ_TIME", "POOL_WRITE_TIME", "DIRECT_READS", "DIRECT_WRITES", "DIRECT_READ_REQS", "DIRECT_WRITE_REQS", "DIRECT_READ_TIME", "DIRECT_WRITE_TIME", "UNREAD_PREFETCH_PAGES", "LOCKS_HELD", "LOCK_WAITS", "LOCK_WAIT_TIME", "LOCK_ESCALS", "X_LOCK_ESCALS", "DEADLOCKS", "TOTAL_SORTS", "TOTAL_SORT_TIME", "SORT_OVERFLOWS", "COMMIT_SQL_STMTS", "ROLLBACK_SQL_STMTS", "DYNAMIC_SQL_STMTS", "STATIC_SQL_STMTS", "FAILED_SQL_STMTS", "SELECT_SQL_STMTS", "DDL_SQL_STMTS", "UID_SQL_STMTS", "INT_AUTO_REBINDS", "INT_ROWS_DELETED", "INT_ROWS_UPDATED", "INT_COMMITS", "INT_ROLLBACKS", "INT_DEADLOCK_ROLLBACKS", "ROWS_DELETED", "ROWS_INSERTED", "ROWS_UPDATED", "ROWS_SELECTED", "BINDS_PRECOMPILES", "OPEN_REM_CURS", "OPEN_REM_CURS_BLK", "REJ_CURS_BLK", "ACC_CURS_BLK", "SQL_REQS_SINCE_COMMIT", "LOCK_TIMEOUTS", "INT_ROWS_INSERTED", "OPEN_LOC_CURS", "OPEN_LOC_CURS_BLK", "PKG_CACHE_LOOKUPS", "PKG_CACHE_INSERTS", "CAT_CACHE_LOOKUPS", "CAT_CACHE_INSERTS", "CAT_CACHE_OVERFLOWS", "NUM_AGENTS", "AGENTS_STOLEN", "ASSOCIATED_AGENTS_TOP", "APPL_PRIORITY", "APPL_PRIORITY_TYPE", "PREFETCH_WAIT_TIME", "APPL_SECTION_LOOKUPS", "APPL_SECTION_INSERTS", "LOCKS_WAITING", "TOTAL_HASH_JOINS", "TOTAL_HASH_LOOPS", "HASH_JOIN_OVERFLOWS", "HASH_JOIN_SMALL_OVERFLOWS", "APPL_IDLE_TIME", "UOW_LOCK_WAIT_TIME", "UOW_COMP_STATUS", "AGENT_USR_CPU_TIME_S", "AGENT_USR_CPU_TIME_MS", "AGENT_SYS_CPU_TIME_S", "AGENT_SYS_CPU_TIME_MS", "APPL_CON_TIME", "CONN_COMPLETE_TIME", "LAST_RESET", "UOW_START_TIME", "UOW_STOP_TIME", "PREV_UOW_STOP_TIME", "UOW_ELAPSED_TIME_S", "UOW_ELAPSED_TIME_MS", "ELAPSED_EXEC_TIME_S", "ELAPSED_EXEC_TIME_MS", "INBOUND_COMM_ADDRESS", "LOCK_TIMEOUT_VAL", "PRIV_WORKSPACE_NUM_OVERFLOWS", "PRIV_WORKSPACE_SECTION_INSERTS", "PRIV_WORKSPACE_SECTION_LOOKUPS", "PRIV_WORKSPACE_SIZE_TOP", "SHR_WORKSPACE_NUM_OVERFLOWS", "SHR_WORKSPACE_SECTION_INSERTS", "SHR_WORKSPACE_SECTION_LOOKUPS", "SHR_WORKSPACE_SIZE_TOP", "DBPARTITIONNUM", "CAT_CACHE_SIZE_TOP", "TOTAL_OLAP_FUNCS", "OLAP_FUNC_OVERFLOWS") AS
SELECT  snapshot_timestamp, db_name, agent_id, uow_log_space_used, rows_read,  rows_written, inact_stmthist_sz, pool_data_l_reads, pool_data_p_reads,  pool_data_writes, pool_index_l_reads, pool_index_p_reads, pool_index_writes,  pool_temp_data_l_reads, pool_temp_data_p_reads, pool_temp_index_l_reads,  pool_temp_index_p_reads, pool_temp_xda_l_reads, pool_temp_xda_p_reads, pool_xda_l_reads,  pool_xda_p_reads, pool_xda_writes, pool_read_time, pool_write_time, direct_reads,  direct_writes, direct_read_reqs, direct_write_reqs, direct_read_time, direct_write_time,  unread_prefetch_pages,  locks_held, lock_waits,  lock_wait_time,  lock_escals, x_lock_escals,  deadlocks, total_sorts, total_sort_time, sort_overflows, commit_sql_stmts,  rollback_sql_stmts, dynamic_sql_stmts, static_sql_stmts, failed_sql_stmts,  select_sql_stmts, ddl_sql_stmts, uid_sql_stmts, int_auto_rebinds, int_rows_deleted,  int_rows_updated, int_commits, int_rollbacks, int_deadlock_rollbacks, rows_deleted,  rows_inserted, rows_updated, rows_selected, binds_precompiles, open_rem_curs,  open_rem_curs_blk, rej_curs_blk, acc_curs_blk, sql_reqs_since_commit, lock_timeouts,  int_rows_inserted, open_loc_curs, open_loc_curs_blk, pkg_cache_lookups,  pkg_cache_inserts, cat_cache_lookups, cat_cache_inserts, cat_cache_overflows, num_agents,  agents_stolen, associated_agents_top, appl_priority, appl_priority_type, prefetch_wait_time,  appl_section_lookups, appl_section_inserts, locks_waiting, total_hash_joins,  total_hash_loops, hash_join_overflows, hash_join_small_overflows, appl_idle_time,  uow_lock_wait_time, uow_comp_status, agent_usr_cpu_time_s, agent_usr_cpu_time_ms,  agent_sys_cpu_time_s, agent_sys_cpu_time_ms, appl_con_time, conn_complete_time,  last_reset, uow_start_time, uow_stop_time, prev_uow_stop_time, uow_elapsed_time_s,  uow_elapsed_time_ms, elapsed_exec_time_s, elapsed_exec_time_ms, inbound_comm_address,  lock_timeout_val, priv_workspace_num_overflows, priv_workspace_section_inserts,  priv_workspace_section_lookups, priv_workspace_size_top, shr_workspace_num_overflows,  shr_workspace_section_inserts, shr_workspace_section_lookups, shr_workspace_size_top,  dbpartitionnum, cat_cache_size_top, total_olap_funcs, olap_func_overflows FROM TABLE(SYSPROC.SNAP_GET_APPL_V95(' ')) as T;

CREATE VIEW "SYSIBMADM"."APPL_PERFORMANCE" ("SNAPSHOT_TIMESTAMP", "AUTHID", "APPL_NAME", "AGENT_ID", "PERCENT_ROWS_SELECTED", "DBPARTITIONNUM") AS
SELECT  AI.SNAPSHOT_TIMESTAMP, AI.PRIMARY_AUTH_ID, AI.APPL_NAME, AI.AGENT_ID, CASE WHEN AP.ROWS_READ > 0 AND AP.ROWS_SELECTED <= AP.ROWS_READ   THEN DEC((FLOAT(AP.ROWS_SELECTED)/FLOAT(AP.ROWS_READ))*100,5,2)  WHEN AP.ROWS_READ > 0 AND AP.ROWS_SELECTED > AP.ROWS_READ   THEN 100.00  ELSE NULL END, AI.DBPARTITIONNUM FROM SYSIBMADM.SNAPAPPL_INFO AI, SYSIBMADM.SNAPAPPL AP WHERE AI.AGENT_ID = AP.AGENT_ID AND AI.DBPARTITIONNUM = AP.DBPARTITIONNUM;

CREATE VIEW "SYSIBMADM"."AUTHORIZATIONIDS" ("AUTHID", "AUTHIDTYPE") AS
SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSCOLAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSDBAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSINDEXAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSLIBRARYAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSPASSTHRUAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSPLANAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSROUTINEAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSSCHEMAAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSSEQUENCEAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSTABAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSTBSPACEAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSXSROBJECTAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSVARIABLEAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSWORKLOADAUTH   UNION   SELECT GRANTEE, GRANTEETYPE FROM SYSIBM.SYSMODULEAUTH;

CREATE VIEW "SYSIBMADM"."SNAPBP" ("SNAPSHOT_TIMESTAMP", "BP_NAME", "DB_NAME", "DB_PATH", "INPUT_DB_ALIAS", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_DATA_WRITES", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_INDEX_WRITES", "POOL_XDA_L_READS", "POOL_XDA_P_READS", "POOL_XDA_WRITES", "POOL_READ_TIME", "POOL_WRITE_TIME", "POOL_ASYNC_DATA_READS", "POOL_ASYNC_DATA_WRITES", "POOL_ASYNC_INDEX_READS", "POOL_ASYNC_INDEX_WRITES", "POOL_ASYNC_XDA_READS", "POOL_ASYNC_XDA_WRITES", "POOL_ASYNC_READ_TIME", "POOL_ASYNC_WRITE_TIME", "POOL_ASYNC_DATA_READ_REQS", "POOL_ASYNC_INDEX_READ_REQS", "POOL_ASYNC_XDA_READ_REQS", "DIRECT_READS", "DIRECT_WRITES", "DIRECT_READ_REQS", "DIRECT_WRITE_REQS", "DIRECT_READ_TIME", "DIRECT_WRITE_TIME", "UNREAD_PREFETCH_PAGES", "FILES_CLOSED", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_TEMP_XDA_L_READS", "POOL_TEMP_XDA_P_READS", "POOL_NO_VICTIM_BUFFER", "PAGES_FROM_BLOCK_IOS", "PAGES_FROM_VECTORED_IOS", "VECTORED_IOS", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, bp_name, db_name, db_path, input_db_alias, pool_data_l_reads,  pool_data_p_reads, pool_data_writes, pool_index_l_reads, pool_index_p_reads,  pool_index_writes, pool_xda_l_reads, pool_xda_p_reads, pool_xda_writes, pool_read_time,  pool_write_time, pool_async_data_reads, pool_async_data_writes, pool_async_index_reads,  pool_async_index_writes, pool_async_xda_reads, pool_async_xda_writes,  pool_async_read_time, pool_async_write_time, pool_async_data_read_reqs,  pool_async_index_read_reqs, pool_async_xda_read_reqs, direct_reads,  direct_writes, direct_read_reqs, direct_write_reqs, direct_read_time,  direct_write_time, unread_prefetch_pages,  files_closed, pool_temp_data_l_reads, pool_temp_data_p_reads, pool_temp_index_l_reads,  pool_temp_index_p_reads, pool_temp_xda_l_reads, pool_temp_xda_p_reads, pool_no_victim_buffer,  pages_from_block_ios, pages_from_vectored_ios, vectored_ios,  dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_BP_V95(' ')) as T;

CREATE VIEW "SYSIBMADM"."BP_HITRATIO" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "BP_NAME", "TOTAL_LOGICAL_READS", "TOTAL_PHYSICAL_READS", "TOTAL_HIT_RATIO_PERCENT", "DATA_LOGICAL_READS", "DATA_PHYSICAL_READS", "DATA_HIT_RATIO_PERCENT", "INDEX_LOGICAL_READS", "INDEX_PHYSICAL_READS", "INDEX_HIT_RATIO_PERCENT", "XDA_LOGICAL_READS", "XDA_PHYSICAL_READS", "XDA_HIT_RATIO_PERCENT", "DBPARTITIONNUM") AS
WITH BP_DATA AS  ( SELECT SNAPSHOT_TIMESTAMP, DB_NAME, BP_NAME, POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS AS TOTAL_DATA_LOGICAL_READS, POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS AS TOTAL_INDEX_LOGICAL_READS, POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS AS TOTAL_XDA_LOGICAL_READS,  POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS AS TOTAL_DATA_PHYSICAL_READS, POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS AS TOTAL_INDEX_PHYSICAL_READS, POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS AS TOTAL_XDA_PHYSICAL_READS,  DBPARTITIONNUM FROM SYSIBMADM.SNAPBP) SELECT  SNAPSHOT_TIMESTAMP, DB_NAME, BP_NAME, TOTAL_DATA_LOGICAL_READS + TOTAL_INDEX_LOGICAL_READS + TOTAL_XDA_LOGICAL_READS AS TOTAL_LOGICAL_READS, TOTAL_DATA_PHYSICAL_READS + TOTAL_INDEX_PHYSICAL_READS + TOTAL_XDA_PHYSICAL_READS AS TOTAL_PHYSICAL_READS, CASE WHEN (TOTAL_DATA_LOGICAL_READS + TOTAL_INDEX_LOGICAL_READS + TOTAL_XDA_LOGICAL_READS) > 0  THEN DEC((1 - (FLOAT(TOTAL_DATA_PHYSICAL_READS + TOTAL_INDEX_PHYSICAL_READS + TOTAL_XDA_PHYSICAL_READS) / FLOAT(TOTAL_DATA_LOGICAL_READS + TOTAL_INDEX_LOGICAL_READS + TOTAL_XDA_LOGICAL_READS))) * 100,5,2)  ELSE NULL END AS TOTAL_HIT_RATIO, TOTAL_DATA_LOGICAL_READS, TOTAL_DATA_PHYSICAL_READS, CASE WHEN TOTAL_DATA_LOGICAL_READS > 0  THEN DEC((1 - (FLOAT(TOTAL_DATA_PHYSICAL_READS) / FLOAT(TOTAL_DATA_LOGICAL_READS))) * 100,5,2)  ELSE NULL END AS DATA_HIT_RATIO, TOTAL_INDEX_LOGICAL_READS, TOTAL_INDEX_PHYSICAL_READS, CASE WHEN TOTAL_INDEX_LOGICAL_READS > 0  THEN DEC((1 - (FLOAT(TOTAL_INDEX_PHYSICAL_READS) / FLOAT(TOTAL_INDEX_LOGICAL_READS))) * 100,5,2)  ELSE NULL END AS INDEX_HIT_RATIO, TOTAL_XDA_LOGICAL_READS, TOTAL_XDA_PHYSICAL_READS, CASE WHEN TOTAL_XDA_LOGICAL_READS > 0  THEN DEC((1 - (FLOAT(TOTAL_XDA_PHYSICAL_READS) / FLOAT(TOTAL_XDA_LOGICAL_READS))) * 100,5,2)  ELSE NULL END AS XDA_HIT_RATIO, DBPARTITIONNUM FROM BP_DATA;

CREATE VIEW "SYSIBMADM"."BP_READ_IO" ("SNAPSHOT_TIMESTAMP", "BP_NAME", "TOTAL_PHYSICAL_READS", "AVERAGE_READ_TIME_MS", "TOTAL_ASYNC_READS", "AVERAGE_ASYNC_READ_TIME_MS", "TOTAL_SYNC_READS", "AVERAGE_SYNC_READ_TIME_MS", "PERCENT_SYNC_READS", "ASYNC_NOT_READ_PERCENT", "DBPARTITIONNUM") AS
WITH BP_DATA AS ( SELECT SNAPSHOT_TIMESTAMP, BP_NAME, POOL_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_DATA_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS AS TOTAL_READS, POOL_ASYNC_DATA_READS + POOL_ASYNC_INDEX_READS + POOL_ASYNC_XDA_READS AS TOTAL_ASYNC, UNREAD_PREFETCH_PAGES, POOL_READ_TIME, POOL_ASYNC_READ_TIME, DBPARTITIONNUM FROM SYSIBMADM.SNAPBP) SELECT  SNAPSHOT_TIMESTAMP, BP_NAME, TOTAL_READS, CASE WHEN TOTAL_READS > 0  THEN POOL_READ_TIME / TOTAL_READS  ELSE NULL END, TOTAL_ASYNC, CASE WHEN TOTAL_ASYNC > 0  THEN POOL_ASYNC_READ_TIME / TOTAL_ASYNC  ELSE NULL END, TOTAL_READS - TOTAL_ASYNC, CASE WHEN (TOTAL_READS - TOTAL_ASYNC) > 0  THEN (POOL_READ_TIME - POOL_ASYNC_READ_TIME) / (TOTAL_READS - TOTAL_ASYNC)  ELSE NULL END, CASE WHEN TOTAL_READS > 0  THEN DEC(100 * FLOAT(TOTAL_READS - TOTAL_ASYNC) / FLOAT(TOTAL_READS), 5,2)  ELSE NULL END, CASE WHEN TOTAL_READS > 0  THEN DEC(100 * FLOAT(UNREAD_PREFETCH_PAGES) / FLOAT(TOTAL_READS), 5,2)  ELSE NULL END, DBPARTITIONNUM FROM BP_DATA;

CREATE VIEW "SYSIBMADM"."BP_WRITE_IO" ("SNAPSHOT_TIMESTAMP", "BP_NAME", "TOTAL_WRITES", "AVERAGE_WRITE_TIME_MS", "TOTAL_ASYNC_WRITES", "PERCENT_WRITES_ASYNC", "AVERAGE_ASYNC_WRITE_TIME_MS", "TOTAL_SYNC_WRITES", "AVERAGE_SYNC_WRITE_TIME_MS", "DBPARTITIONNUM") AS
WITH BP_DATA AS ( SELECT SNAPSHOT_TIMESTAMP, BP_NAME, POOL_DATA_WRITES + POOL_INDEX_WRITES + POOL_XDA_WRITES AS TOTAL_WRITES, POOL_ASYNC_DATA_WRITES + POOL_ASYNC_INDEX_WRITES + POOL_ASYNC_XDA_WRITES AS TOTAL_ASYNC, POOL_WRITE_TIME, POOL_ASYNC_WRITE_TIME, DBPARTITIONNUM FROM SYSIBMADM.SNAPBP ) SELECT  SNAPSHOT_TIMESTAMP, BP_NAME, TOTAL_WRITES, CASE WHEN TOTAL_WRITES > 0  THEN POOL_WRITE_TIME / TOTAL_WRITES  ELSE NULL END, TOTAL_ASYNC, CASE WHEN TOTAL_WRITES > 0  THEN ((TOTAL_ASYNC * 100) / TOTAL_WRITES)  ELSE NULL END, CASE WHEN TOTAL_ASYNC > 0  THEN POOL_ASYNC_WRITE_TIME / TOTAL_ASYNC  ELSE NULL END, TOTAL_WRITES - TOTAL_ASYNC, CASE WHEN (TOTAL_WRITES - TOTAL_ASYNC) > 0  THEN (POOL_WRITE_TIME - POOL_ASYNC_WRITE_TIME) / (TOTAL_WRITES - TOTAL_ASYNC)  ELSE NULL END, DBPARTITIONNUM FROM BP_DATA;

CREATE VIEW "SYSIBMADM"."CONTACTGROUPS" ("NAME", "DESCRIPTION", "MEMBERNAME", "MEMBERTYPE") AS
SELECT  CONTACTGROUPS.NAME, CONTACTGROUPS.DESCRIPTION,  CONTACTGROUPS.MEMBERNAME, CONTACTGROUPS.MEMBERTYPE FROM TABLE(SYSPROC.ADMIN_GET_CONTACTGROUPS()) AS CONTACTGROUPS;

CREATE VIEW "SYSIBMADM"."CONTACTS" ("NAME", "TYPE", "ADDRESS", "MAX_PAGE_LENGTH", "DESCRIPTION") AS
SELECT  CONTACTS.NAME, CONTACTS.TYPE, CONTACTS.ADDRESS,  CONTACTS.MAX_PAGE_LENGTH, CONTACTS.DESCRIPTION FROM TABLE(SYSPROC.ADMIN_GET_CONTACTS()) AS CONTACTS;

CREATE VIEW "SYSIBMADM"."SNAPCONTAINER" ("SNAPSHOT_TIMESTAMP", "TBSP_NAME", "TBSP_ID", "CONTAINER_NAME", "CONTAINER_ID", "CONTAINER_TYPE", "TOTAL_PAGES", "USABLE_PAGES", "ACCESSIBLE", "STRIPE_SET", "DBPARTITIONNUM", "FS_ID", "FS_TOTAL_SIZE", "FS_USED_SIZE") AS
SELECT  SNAPSHOT_TIMESTAMP, TBSP_NAME, TBSP_ID, CONTAINER_NAME, CONTAINER_ID, CONTAINER_TYPE,  TOTAL_PAGES, USABLE_PAGES, ACCESSIBLE, STRIPE_SET, DBPARTITIONNUM, FS_ID,  FS_TOTAL_SIZE, FS_USED_SIZE FROM TABLE(SYSPROC.SNAP_GET_CONTAINER_V91('')) as T;

CREATE VIEW "SYSIBMADM"."CONTAINER_UTILIZATION" ("SNAPSHOT_TIMESTAMP", "TBSP_NAME", "TBSP_ID", "CONTAINER_NAME", "CONTAINER_ID", "CONTAINER_TYPE", "TOTAL_PAGES", "USABLE_PAGES", "ACCESSIBLE", "STRIPE_SET", "FS_ID", "FS_TOTAL_SIZE_KB", "FS_USED_SIZE_KB", "DBPARTITIONNUM") AS
SELECT  SNAPSHOT_TIMESTAMP, TBSP_NAME, TBSP_ID, CONTAINER_NAME, CONTAINER_ID, CONTAINER_TYPE, TOTAL_PAGES, USABLE_PAGES, ACCESSIBLE, STRIPE_SET, FS_ID, FS_TOTAL_SIZE / 1024, FS_USED_SIZE / 1024, DBPARTITIONNUM FROM SYSIBMADM.SNAPCONTAINER;

CREATE VIEW "SYSIBMADM"."DBA_ALL_TABLES" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
SELECT * FROM SYSIBMADM.DBA_TABLES;

CREATE VIEW "SYSIBMADM"."DBA_ARGUMENTS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "PACKAGE_NAME", "OBJECT_ID", "ARGUMENT_NAME", "SEQUENCE", "DATA_TYPE", "IN_OUT", "DATA_LENGTH", "DATA_SCALE") AS
SELECT    RT.OWNER   ,RP.ROUTINESCHEMA   ,RP.ROUTINENAME   ,RP.ROUTINEMODULENAME   ,RT.ROUTINEID   ,RP.PARMNAME   ,RP.ORDINAL   ,RP.TYPENAME   ,CAST( CASE RP.ROWTYPE    WHEN 'B' THEN 'IN/OUT'    WHEN 'O' THEN 'OUT'    WHEN 'P' THEN 'IN'    END AS VARCHAR(6) )  ,RP.LENGTH   ,RP.SCALE  FROM SYSCAT.ROUTINEPARMS RP, SYSCAT.ROUTINES RT  WHERE RP.ROUTINESCHEMA = RT.ROUTINESCHEMA AND RP.ROUTINENAME = RT.ROUTINENAME   AND RP.ROWTYPE IN ('B','O','P');

CREATE VIEW "SYSIBMADM"."DBA_CATALOG" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE") AS
SELECT OWNER, SEQSCHEMA, SEQNAME,        CAST( CASE WHEN SEQTYPE = 'A' THEN 'SYNONYM'       ELSE 'SEQUENCE'       END AS VARCHAR(8) ) FROM SYSCAT.SEQUENCES UNION ALL SELECT OWNER, TABSCHEMA, TABNAME,       CAST( CASE WHEN (TYPE = 'V' OR TYPE = 'W') THEN 'VIEW'            WHEN TYPE = 'A' THEN 'SYNONYM'            ELSE 'TABLE' END AS VARCHAR(8) ) FROM SYSCAT.TABLES WHERE TYPE != 'N' UNION ALL SELECT OWNER, MODULESCHEMA, MODULENAME, CAST( 'SYNONYM' AS VARCHAR(8) ) FROM SYSCAT.MODULES WHERE MODULETYPE = 'A';

CREATE VIEW "SYSIBMADM"."DBA_DEPENDENCIES" ("OWNER", "SCHEMA", "NAME", "TYPE", "REFERENCED_SCHEMA", "REFERENCED_NAME", "REFERENCED_TYPE") AS
SELECT TC.OWNER, CAST( NULL AS VARCHAR(128) ), CD.CONSTNAME, CAST( 'CONSTRAINT' AS VARCHAR(15) ),       CD.BSCHEMA, CD.BNAME,       CAST( CASE CD.BTYPE          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'R' THEN 'STRUCTURED TYPE'       END AS VARCHAR(20) ) FROM SYSCAT.CONSTDEP CD, SYSCAT.TABCONST TC WHERE CD.CONSTNAME = TC.CONSTNAME AND CD.TABSCHEMA = TC.TABSCHEMA   AND CD.TABNAME = TC.TABNAME UNION ALL SELECT IX.OWNER, IXDEP.INDSCHEMA, IXDEP.INDNAME, 'INDEX',       IXDEP.BSCHEMA, IXDEP.BNAME,       CAST( CASE IXDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END AS VARCHAR(20) ) FROM SYSCAT.INDEXDEP IXDEP, SYSCAT.INDEXES IX WHERE IXDEP.INDNAME = IX.INDNAME AND IXDEP.INDSCHEMA = IX.INDSCHEMA UNION ALL SELECT PKG.OWNER, PDEP.PKGSCHEMA, PDEP.PKGNAME, 'DB2 PACKAGE',       PDEP.BSCHEMA, PDEP.BNAME,       CASE PDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'D' THEN 'SERVER DEFINITION'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'M' THEN 'FUNCTION MAPPING'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'P' THEN 'PAGE SIZE'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.PACKAGEDEP PDEP, SYSCAT.PACKAGES PKG WHERE PDEP.PKGSCHEMA = PKG.PKGSCHEMA AND PDEP.PKGNAME = PKG.PKGNAME UNION ALL SELECT RT.OWNER, RDEP.ROUTINESCHEMA, RT.ROUTINENAME,       CASE RT.ROUTINETYPE          WHEN 'P' THEN 'PROCEDURE'          WHEN 'F' THEN 'FUNCTION'          WHEN 'M' THEN 'METHOD'       END,       RDEP.BSCHEMA, RDEP.BNAME,       CASE RDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.ROUTINEDEP RDEP, SYSCAT.ROUTINES RT WHERE RDEP.ROUTINESCHEMA = RT.ROUTINESCHEMA AND RDEP.SPECIFICNAME = RT.SPECIFICNAME UNION ALL SELECT TAB.OWNER, TDEP.TABSCHEMA, TDEP.TABNAME,        CASE TAB.TYPE          WHEN 'U' THEN 'VIEW'          WHEN 'V' THEN 'VIEW'          ELSE 'TABLE'       END,       TDEP.BSCHEMA, TDEP.BNAME,       CASE TDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'I' THEN 'INDEX'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.TABDEP TDEP, SYSCAT.TABLES TAB WHERE TDEP.TABSCHEMA = TAB.TABSCHEMA AND TDEP.TABNAME = TAB.TABNAME UNION ALL SELECT TAB.OWNER, TDEP.TABSCHEMA, TDEP.TABNAME, 'TABLE',       TDEP.DEPTABSCHEMA, TDEP.DEPTABNAME, 'TABLE' FROM SYSCAT.TABDETACHEDDEP TDEP, SYSCAT.TABLES TAB WHERE TDEP.TABSCHEMA = TAB.TABSCHEMA AND TDEP.TABNAME = TAB.TABNAME UNION ALL SELECT TRG.OWNER, TGDEP.TRIGSCHEMA, TGDEP.TRIGNAME, 'TRIGGER',       TGDEP.BSCHEMA, TGDEP.BNAME,       CASE TGDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'B' THEN 'TRIGGER'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'K' THEN 'DB2 PACKAGE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'Q' THEN 'SEQUENCE'          WHEN 'R' THEN 'STRUCTURE TYPE'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'X' THEN 'INDEX EXTENSION'          WHEN 'Z' THEN 'XSR OBJECT'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.TRIGDEP TGDEP, SYSCAT.TRIGGERS TRG WHERE TGDEP.TRIGSCHEMA = TRG.TRIGSCHEMA AND TGDEP.TRIGNAME = TRG.TRIGNAME UNION ALL SELECT VAR.OWNER, VDEP.VARSCHEMA, VDEP.VARNAME, 'GLOBAL VARIABLE',       VDEP.BSCHEMA, VDEP.BNAME,       CASE VDEP.BTYPE          WHEN 'A' THEN 'SYNONYM'          WHEN 'F' THEN 'ROUTINE INSTANCE'          WHEN 'O' THEN 'PRIVILEGE DEPENDENCY'          WHEN 'V' THEN 'VIEW'          WHEN 'W' THEN 'VIEW'          WHEN 'v' THEN 'GLOBAL VARIABLE'          ELSE 'TABLE'       END FROM SYSCAT.VARIABLEDEP VDEP, SYSCAT.VARIABLES VAR WHERE VDEP.VARSCHEMA = VAR.VARSCHEMA AND VDEP.VARNAME = VAR.VARNAME;

CREATE VIEW "SYSIBMADM"."DBA_ERRORS" ("OWNER", "SCHEMA", "NAME", "TYPE", "LINE", "TEXT") AS
SELECT     TRIG.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,CAST( 'TRIGGER' AS VARCHAR(15) )   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.TRIGGERS TRIG WHERE OBJ.OBJECTTYPE = 'B' AND OBJ.OBJECTSCHEMA = TRIG.TRIGSCHEMA AND OBJ.OBJECTNAME = TRIG.TRIGNAME UNION ALL SELECT     ROUT.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'ROUTINE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.ROUTINES ROUT WHERE OBJ.OBJECTTYPE = 'F' AND OBJ.OBJECTSCHEMA = ROUT.ROUTINESCHEMA AND OBJ.OBJECTNAME = ROUT.SPECIFICNAME UNION ALL SELECT     TYPE.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'DATATYPE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.DATATYPES TYPE WHERE OBJ.OBJECTTYPE = 'R' AND OBJ.OBJECTSCHEMA = TYPE.TYPESCHEMA AND OBJ.OBJECTNAME = TYPE.TYPENAME UNION ALL SELECT     VIEW.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'VIEW'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.VIEWS VIEW WHERE OBJ.OBJECTTYPE = 'V' AND OBJ.OBJECTSCHEMA = VIEW.VIEWSCHEMA AND OBJ.OBJECTNAME = VIEW.VIEWNAME UNION ALL SELECT     VAR.OWNER   ,OBJECTSCHEMA   ,OBJECTNAME   ,'GLOBAL VARIABLE'   ,LINENUMBER   ,CASE WHEN SQLCODE IS NULL THEN NULL ELSE SQLERRM(CONCAT('SQL', CHAR(ABS(SQLCODE))), SQLERRMC, x'FF', 'en_US', 1) END FROM SYSIBM.SYSINVALIDOBJECTS OBJ, SYSCAT.VARIABLES VAR WHERE OBJ.OBJECTTYPE = 'v' AND OBJ.OBJECTSCHEMA = VAR.VARSCHEMA AND OBJ.OBJECTNAME = VAR.VARNAME;

CREATE VIEW "SYSIBMADM"."DBA_OBJECTS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_ID", "DATA_OBJECT_ID", "OBJECT_TYPE", "CREATED", "LAST_DDL_TIME", "TIMESTAMP", "STATUS", "TEMPORARY", "GENERATED") AS
WITH RAUTH AS (SELECT SCHEMA, SPECIFICNAME, MAX(GRANT_TIME) AS GRANT_TIME                FROM SYSCAT.ROUTINEAUTH GROUP BY SCHEMA, SPECIFICNAME) SELECT DISTINCT OWNER, ROUTINESCHEMA, ROUTINENAME, ROUTINEID, CAST(NULL AS INTEGER),        CAST( CASE          WHEN ROUTINETYPE = 'F' THEN 'FUNCTION'          WHEN ROUTINETYPE = 'P' THEN 'PROCEDURE'          WHEN ROUTINETYPE = 'M' THEN 'METHOD'         ELSE 'UNKNOWN'         END AS VARCHAR(9) ),       CREATE_TIME, GREATEST(ALTER_TIME, GRANT_TIME), CAST(CREATE_TIME AS CHAR(26)), CAST( 'VALID' AS VARCHAR(5) ), CAST( 'N' AS VARCHAR(1) ),        CAST( CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END AS VARCHAR(1) )       FROM SYSCAT.ROUTINES RT, RAUTH RA       WHERE RT.ROUTINESCHEMA = RA.SCHEMA AND RT.SPECIFICNAME = RA.SPECIFICNAME UNION ALL SELECT DISTINCT OWNER, INDSCHEMA, INDNAME, IID, TBSPACEID, 'INDEX',       CREATE_TIME, CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)),        'VALID', 'N',       CASE WHEN (OWNERTYPE = 'S') OR (INDNAME LIKE 'SQL%' AND LENGTH(INDNAME) = 18) THEN 'Y'            ELSE 'N' END       FROM SYSCAT.INDEXES UNION ALL SELECT DISTINCT OWNER, SEQSCHEMA, SEQNAME, SEQID, CAST(NULL AS INTEGER),        CASE SEQTYPE WHEN 'A' THEN 'SYNONYM' ELSE 'SEQUENCE' END,       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE WHEN (OWNERTYPE = 'S') OR (SEQNAME LIKE 'SQL%' AND LENGTH(SEQNAME) = 18) THEN 'Y'            ELSE 'N' END       FROM SYSCAT.SEQUENCES UNION ALL SELECT DISTINCT OWNER, TABSCHEMA, TABNAME, TABLEID, TBSPACEID,       CASE WHEN (TYPE = 'V' OR TYPE = 'W') THEN 'VIEW'            WHEN TYPE = 'A' THEN 'SYNONYM'            WHEN TYPE = 'N' THEN 'DB_LINK'            WHEN TYPE = 'S' THEN 'MATERIALIZED QUERY TABLE'            ELSE 'TABLE' END,       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)),       CASE STATUS WHEN 'X' THEN 'INVALID' ELSE 'VALID' END,       CASE TYPE WHEN 'G' THEN 'Y' ELSE 'N' END,       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.TABLES UNION ALL SELECT DISTINCT OWNER, TYPESCHEMA, TYPENAME, TYPEID, CAST(NULL AS INTEGER), 'ABSTRACT DATATYPE',       CREATE_TIME, ALTER_TIME, CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.DATATYPES WHERE METATYPE != 'S' UNION ALL SELECT DISTINCT OWNER, TRIGSCHEMA, TRIGNAME, CAST(NULL AS SMALLINT), CAST(NULL AS INTEGER), 'TRIGGER',       CREATE_TIME, CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.TRIGGERS UNION ALL SELECT DISTINCT OWNER, MODULESCHEMA, MODULENAME, MODULEID, CAST(NULL AS INTEGER),       CASE MODULETYPE WHEN 'A' THEN 'SYNONYM' ELSE 'PACKAGE' END,       CREATE_TIME, CAST(NULL AS TIMESTAMP), CAST(CREATE_TIME AS CHAR(26)), 'VALID', 'N',       CASE OWNERTYPE WHEN 'S' THEN 'Y' ELSE 'N' END       FROM SYSCAT.MODULES;

CREATE VIEW "SYSIBMADM"."DBA_ROLES" ("ROLE", "PASSWORD_REQUIRED") AS
SELECT   ROLENAME  ,CAST( 'NO' AS VARCHAR(2) ) FROM SYSCAT.ROLES;

CREATE VIEW "SYSIBMADM"."DBA_ROLE_PRIVS" ("GRANTEE", "GRANTED_ROLE", "ADMIN_OPTION", "DEFAULT_ROLE") AS
SELECT   GRANTEE  ,ROLENAME  ,CAST( CASE ADMIN   WHEN 'Y' THEN 'YES'   WHEN 'N' THEN 'NO'   END AS VARCHAR(3) )  ,CAST( 'YES' AS VARCHAR(3) ) FROM SYSCAT.ROLEAUTH;

CREATE VIEW "SYSIBMADM"."DBA_SOURCE" ("OWNER", "SCHEMA", "NAME", "SPECIFICNAME", "TYPE", "TEXT") AS
SELECT   OWNER  ,ROUTINESCHEMA  ,ROUTINENAME  ,SPECIFICNAME  ,CAST( CASE     WHEN ROUTINETYPE = 'P' THEN 'PROCEDURE'     WHEN ROUTINETYPE = 'F' THEN 'FUNCTION'     WHEN ROUTINETYPE = 'M' THEN 'METHOD'     ELSE'UNKNOWN'   END AS VARCHAR(9) )  ,TEXT FROM SYSCAT.ROUTINES UNION ALL SELECT   OWNER  ,TRIGSCHEMA  ,TRIGNAME  ,CAST( NULL AS VARCHAR(128) )  ,'TRIGGER'  ,TEXT FROM SYSCAT.TRIGGERS UNION ALL SELECT   OWNER  ,MODULESCHEMA  ,MODULENAME  ,CAST( NULL AS VARCHAR(128) )  ,'PACKAGE'  ,SOURCEHEADER FROM SYSIBM.SYSMODULES UNION ALL SELECT   OWNER  ,MODULESCHEMA  ,MODULENAME  ,CAST( NULL AS VARCHAR(128) )  ,'PACKAGE BODY'  ,SOURCEBODY FROM SYSIBM.SYSMODULES WHERE LENGTH(SOURCEBODY) > 1;

CREATE VIEW "SYSIBMADM"."DBA_SYNONYMS" ("OWNER", "SYNONYM_SCHEMA", "SYNONYM_NAME", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME") AS
SELECT   TAB.OWNER  ,TAB.TABSCHEMA  ,TAB.TABNAME  ,REF.OWNER  ,TAB.BASE_TABSCHEMA  ,TAB.BASE_TABNAME FROM SYSCAT.TABLES TAB LEFT OUTER JOIN   SYSCAT.TABLES REF ON TAB.BASE_TABSCHEMA = REF.TABSCHEMA AND TAB.BASE_TABNAME = REF.TABNAME WHERE TAB.TYPE = 'A' UNION ALL SELECT   SEQ.OWNER  ,SEQ.SEQSCHEMA  ,SEQ.SEQNAME  ,REF.OWNER  ,SEQ.BASE_SEQSCHEMA  ,SEQ.BASE_SEQNAME FROM SYSCAT.SEQUENCES SEQ LEFT OUTER JOIN  SYSCAT.SEQUENCES REF ON SEQ.BASE_SEQSCHEMA = REF.SEQSCHEMA AND SEQ.BASE_SEQNAME = REF.SEQNAME WHERE SEQ.SEQTYPE = 'A' UNION ALL SELECT   MOD.OWNER  ,MOD.MODULESCHEMA  ,MOD.MODULENAME  ,REF.OWNER  ,MOD.BASE_MODULESCHEMA  ,MOD.BASE_MODULENAME FROM SYSCAT.MODULES MOD LEFT OUTER JOIN  SYSCAT.MODULES REF ON MOD.BASE_MODULESCHEMA = REF.MODULESCHEMA                         AND MOD.MODULENAME = REF.MODULENAME  WHERE MOD.MODULETYPE = 'A';

CREATE VIEW "SYSIBMADM"."DBA_SYS_PRIVS" ("GRANTEE", "PRIVILEGE", "ADMIN_OPTION") AS
SELECT GRANTEE, CAST( 'BINDADD' AS VARCHAR(25) ), CAST( CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END AS VARCHAR(3) ) FROM SYSCAT.DBAUTH WHERE BINDADDAUTH = 'Y' UNION ALL SELECT GRANTEE, 'CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CONNECTAUTH = 'Y' UNION ALL SELECT GRANTEE, 'CREATETAB', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CREATETABAUTH = 'Y' UNION ALL SELECT GRANTEE, 'DBADM', 'NO' FROM SYSCAT.DBAUTH WHERE DBADMAUTH = 'Y' UNION ALL SELECT GRANTEE, 'CREATE_EXTERNAL_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXTERNALROUTINEAUTH = 'Y' UNION ALL SELECT GRANTEE, 'IMPLICIT_SCHEMA', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE IMPLSCHEMAAUTH = 'Y' UNION ALL SELECT GRANTEE, 'LOAD', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LOADAUTH = 'Y' UNION ALL SELECT GRANTEE, 'CREATE_NOT_FENCED_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE NOFENCEAUTH = 'Y' UNION ALL SELECT GRANTEE, 'QUIESCE_CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE QUIESCECONNECTAUTH = 'Y' UNION ALL SELECT GRANTEE, 'LIBADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LIBRARYADMAUTH = 'Y' UNION ALL SELECT GRANTEE, 'SECADM', 'NO' FROM SYSCAT.DBAUTH WHERE SECURITYADMAUTH = 'Y' UNION ALL SELECT GRANTEE, 'SQLADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE SQLADMAUTH = 'Y' UNION ALL SELECT GRANTEE, 'WLMADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE WLMADMAUTH = 'Y' UNION ALL SELECT GRANTEE, 'EXPLAIN', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXPLAINAUTH = 'Y' UNION ALL SELECT GRANTEE, 'DATAACCESS', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE DATAACCESSAUTH = 'Y' UNION ALL SELECT GRANTEE, 'ACCESSCTRL', CASE  DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE ACCESSCTRLAUTH = 'Y';

CREATE VIEW "SYSIBMADM"."SNAPTBSP" ("SNAPSHOT_TIMESTAMP", "TBSP_NAME", "TBSP_ID", "TBSP_TYPE", "TBSP_CONTENT_TYPE", "TBSP_PAGE_SIZE", "TBSP_EXTENT_SIZE", "TBSP_PREFETCH_SIZE", "TBSP_CUR_POOL_ID", "TBSP_NEXT_POOL_ID", "FS_CACHING", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_ASYNC_DATA_READS", "POOL_DATA_WRITES", "POOL_ASYNC_DATA_WRITES", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_ASYNC_INDEX_READS", "POOL_INDEX_WRITES", "POOL_ASYNC_INDEX_WRITES", "POOL_XDA_L_READS", "POOL_XDA_P_READS", "POOL_XDA_WRITES", "POOL_ASYNC_XDA_READS", "POOL_ASYNC_XDA_WRITES", "POOL_TEMP_XDA_L_READS", "POOL_TEMP_XDA_P_READS", "POOL_READ_TIME", "POOL_WRITE_TIME", "POOL_ASYNC_READ_TIME", "POOL_ASYNC_WRITE_TIME", "POOL_ASYNC_DATA_READ_REQS", "POOL_ASYNC_INDEX_READ_REQS", "POOL_ASYNC_XDA_READ_REQS", "POOL_NO_VICTIM_BUFFER", "DIRECT_READS", "DIRECT_WRITES", "DIRECT_READ_REQS", "DIRECT_WRITE_REQS", "DIRECT_READ_TIME", "DIRECT_WRITE_TIME", "FILES_CLOSED", "UNREAD_PREFETCH_PAGES", "TBSP_REBALANCER_MODE", "TBSP_USING_AUTO_STORAGE", "TBSP_AUTO_RESIZE_ENABLED", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, tbsp_name, tbsp_id, tbsp_type, tbsp_content_type,  tbsp_page_size, tbsp_extent_size, tbsp_prefetch_size, tbsp_cur_pool_id,  tbsp_next_pool_id, fs_caching, pool_data_l_reads, pool_data_p_reads,  pool_temp_data_l_reads, pool_temp_data_p_reads, pool_async_data_reads,  pool_data_writes, pool_async_data_writes, pool_index_l_reads,  pool_index_p_reads, pool_temp_index_l_reads, pool_temp_index_p_reads,  pool_async_index_reads, pool_index_writes, pool_async_index_writes,  pool_xda_l_reads, pool_xda_p_reads, pool_xda_writes, pool_async_xda_reads,  pool_async_xda_writes, pool_temp_xda_l_reads, pool_temp_xda_p_reads,  pool_read_time, pool_write_time, pool_async_read_time, pool_async_write_time,  pool_async_data_read_reqs, pool_async_index_read_reqs, pool_async_xda_read_reqs,  pool_no_victim_buffer, direct_reads, direct_writes, direct_read_reqs, direct_write_reqs,  direct_read_time, direct_write_time, files_closed, unread_prefetch_pages,  tbsp_rebalancer_mode, tbsp_using_auto_storage, tbsp_auto_resize_enabled,  dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_TBSP_V91('')) as t;

CREATE VIEW "SYSIBMADM"."SNAPTBSP_PART" ("SNAPSHOT_TIMESTAMP", "TBSP_NAME", "TBSP_ID", "TBSP_STATE", "TBSP_PREFETCH_SIZE", "TBSP_NUM_QUIESCERS", "TBSP_STATE_CHANGE_OBJECT_ID", "TBSP_STATE_CHANGE_TBSP_ID", "TBSP_MIN_RECOVERY_TIME", "TBSP_TOTAL_PAGES", "TBSP_USABLE_PAGES", "TBSP_USED_PAGES", "TBSP_FREE_PAGES", "TBSP_PENDING_FREE_PAGES", "TBSP_PAGE_TOP", "REBALANCER_MODE", "REBALANCER_EXTENTS_REMAINING", "REBALANCER_EXTENTS_PROCESSED", "REBALANCER_PRIORITY", "REBALANCER_START_TIME", "REBALANCER_RESTART_TIME", "REBALANCER_LAST_EXTENT_MOVED", "TBSP_NUM_RANGES", "TBSP_NUM_CONTAINERS", "TBSP_INITIAL_SIZE", "TBSP_CURRENT_SIZE", "TBSP_MAX_SIZE", "TBSP_INCREASE_SIZE", "TBSP_INCREASE_SIZE_PERCENT", "TBSP_LAST_RESIZE_TIME", "TBSP_LAST_RESIZE_FAILED", "TBSP_PATHS_DROPPED", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, tbsp_name, tbsp_id, tbsp_state, tbsp_prefetch_size,  tbsp_num_quiescers, tbsp_state_change_object_id, tbsp_state_change_tbsp_id,  tbsp_min_recovery_time, tbsp_total_pages, tbsp_usable_pages, tbsp_used_pages,  tbsp_free_pages, tbsp_pending_free_pages, tbsp_page_top, rebalancer_mode,  rebalancer_extents_remaining, rebalancer_extents_processed, rebalancer_priority,  rebalancer_start_time, rebalancer_restart_time, rebalancer_last_extent_moved,  tbsp_num_ranges, tbsp_num_containers, tbsp_initial_size, tbsp_current_size,  tbsp_max_size, tbsp_increase_size, tbsp_increase_size_percent,  tbsp_last_resize_time, tbsp_last_resize_failed, tbsp_paths_dropped,  dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_TBSP_PART_V97('')) as t;

CREATE VIEW "SYSIBMADM"."DBA_TABLESPACES" ("TABLESPACE_NAME", "DBPARTITIONNUM", "BLOCK_SIZE", "INITIAL_EXTENT", "NEXT_EXTENT", "MIN_EXTENTS", "MAX_EXTENTS", "PCT_INCREASE", "MIN_EXTLEN", "STATUS", "CONTENTS", "LOGGING", "SEGMENT_SPACE_MANAGEMENT") AS
SELECT DISTINCT   TBS.TBSPACE  ,SNAPPART.DBPARTITIONNUM  ,TBS.PAGESIZE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,TBS.EXTENTSIZE * TBS.PAGESIZE  ,SNAPPART.TBSP_INITIAL_SIZE  ,CASE   WHEN (SNAPPART.TBSP_MAX_SIZE IS NOT NULL) AND (SNAPPART.TBSP_MAX_SIZE > -1)      THEN SNAPPART.TBSP_MAX_SIZE   END  ,CAST( CASE    WHEN SNAPPART.TBSP_INCREASE_SIZE_PERCENT IS NOT NULL THEN SNAPPART.TBSP_INCREASE_SIZE_PERCENT   WHEN (SNAPPART.TBSP_INCREASE_SIZE IS NOT NULL) AND (SNAPPART.TBSP_INCREASE_SIZE > -1)      THEN (SNAPPART.TBSP_INCREASE_SIZE / SNAPPART.TBSP_CURRENT_SIZE) * 100   END AS DECFLOAT )  ,TBS.EXTENTSIZE  ,CAST( CASE   WHEN LOCATE('OFFLINE',SNAPPART.TBSP_STATE) > 0 THEN 'OFFLINE'   WHEN LOCATE('DROP_PENDING',SNAPPART.TBSP_STATE) > 0 THEN 'INVALID'   ELSE 'ONLINE'   END AS VARCHAR(7) )  ,CAST( CASE TBS.DATATYPE   WHEN 'A' THEN 'PERMANENT'   WHEN 'L' THEN 'PERMANENT'   ELSE 'TEMPORARY'   END AS VARCHAR(9) )  ,CAST( 'LOGGING' AS VARCHAR(7) )  ,CAST( CASE SNAPTBS.TBSP_AUTO_RESIZE_ENABLED   WHEN 1 THEN 'AUTO'   ELSE 'MANUAL'   END AS VARCHAR(6) ) FROM SYSCAT.TABLESPACES TBS, SYSIBMADM.SNAPTBSP SNAPTBS, SYSIBMADM.SNAPTBSP_PART SNAPPART WHERE TBS.TBSPACEID = SNAPTBS.TBSP_ID AND TBS.TBSPACEID = SNAPPART.TBSP_ID;

CREATE VIEW "SYSIBMADM"."DBCFG" ("NAME", "VALUE", "VALUE_FLAGS", "DEFERRED_VALUE", "DEFERRED_VALUE_FLAGS", "DATATYPE", "DBPARTITIONNUM") AS
SELECT  CONFIG.NAME, CONFIG.VALUE, CONFIG.VALUE_FLAGS, CONFIG.DEFERRED_VALUE,  CONFIG.DEFERRED_VALUE_FLAGS, CONFIG.DATATYPE, CONFIG.DBPARTITIONNUM FROM TABLE(SYSPROC.DB_GET_CFG()) AS CONFIG;

CREATE VIEW "SYSIBMADM"."DBMCFG" ("NAME", "VALUE", "VALUE_FLAGS", "DEFERRED_VALUE", "DEFERRED_VALUE_FLAGS", "DATATYPE") AS
SELECT  CONFIG.NAME, CONFIG.VALUE, CONFIG.VALUE_FLAGS, CONFIG.DEFERRED_VALUE, CONFIG.DEFERRED_VALUE_FLAGS, CONFIG.DATATYPE FROM TABLE(SYSPROC.DBM_GET_CFG()) AS CONFIG;

CREATE VIEW "SYSIBMADM"."DBPATHS" ("DBPARTITIONNUM", "TYPE", "PATH") AS
SELECT  DBPARTITIONNUM, TYPE, PATH FROM TABLE(SYSPROC.ADMIN_LIST_DB_PATHS()) AS T;

CREATE VIEW "SYSIBMADM"."DB_HISTORY" ("DBPARTITIONNUM", "EID", "START_TIME", "SEQNUM", "END_TIME", "FIRSTLOG", "LASTLOG", "BACKUP_ID", "TABSCHEMA", "TABNAME", "COMMENT", "CMD_TEXT", "NUM_TBSPS", "TBSPNAMES", "OPERATION", "OPERATIONTYPE", "OBJECTTYPE", "LOCATION", "DEVICETYPE", "ENTRY_STATUS", "SQLCAID", "SQLCABC", "SQLCODE", "SQLERRML", "SQLERRMC", "SQLERRP", "SQLERRD1", "SQLERRD2", "SQLERRD3", "SQLERRD4", "SQLERRD5", "SQLERRD6", "SQLWARN", "SQLSTATE") AS
SELECT  dbpartitionnum, EID, start_time, seqnum, end_time,  firstlog, lastlog, backup_id, tabschema, tabname,  comment, cmd_text, num_tbsps, tbspnames, operation,  operationtype, objecttype, location, devicetype, entry_status,  sqlcaid, sqlcabc, sqlcode, sqlerrml, sqlerrmc, sqlerrp,  sqlerrd1, sqlerrd2, sqlerrd3, sqlerrd4, sqlerrd5, sqlerrd6,  sqlwarn, sqlstate FROM TABLE(SYSPROC.ADMIN_LIST_HIST()) as t;

CREATE VIEW "SYSIBMADM"."DICTIONARY" ("TABLE_SCHEMA", "TABLE_NAME", "COMMENTS") AS
SELECT TABSCHEMA, TABNAME, REMARKS  FROM SYSCAT.TABLES  WHERE (TABNAME LIKE 'USER_%' OR TABNAME LIKE 'DBA_%'         OR TABNAME LIKE 'ALL_%' OR TABNAME LIKE 'ROLE_%'         OR TABNAME LIKE 'SESSION_%' OR TABNAME LIKE 'DICT%')        AND TABSCHEMA='SYSIBMADM';

CREATE VIEW "SYSIBMADM"."DICT_COLUMNS" ("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COMMENTS") AS
SELECT TAB.TABLE_SCHEMA, TAB.TABLE_NAME, COL.COLNAME, COL.REMARKS FROM SYSIBMADM.DICTIONARY TAB, SYSCAT.COLUMNS COL WHERE TAB.TABLE_SCHEMA = COL.TABSCHEMA AND TAB.TABLE_NAME = COL.TABNAME;

CREATE VIEW "SYSIBMADM"."ENV_FEATURE_INFO" ("FEATURE_NAME", "FEATURE_FULLNAME", "LICENSE_INSTALLED", "PRODUCT_NAME", "FEATURE_USE_STATUS") AS
SELECT  feature_name, feature_fullname, license_installed, product_name,  feature_use_status FROM TABLE(SYSPROC.ENV_GET_FEATURE_INFO()) as t;

CREATE VIEW "SYSIBMADM"."ENV_INST_INFO" ("INST_NAME", "IS_INST_PARTITIONABLE", "NUM_DBPARTITIONS", "INST_PTR_SIZE", "RELEASE_NUM", "SERVICE_LEVEL", "BLD_LEVEL", "PTF", "FIXPACK_NUM") AS
SELECT  inst_name, is_inst_partitionable, num_dbpartitions, inst_ptr_size,  release_num, service_level, bld_level, ptf, fixpack_num FROM TABLE(SYSPROC.ENV_GET_INST_INFO()) as t;

CREATE VIEW "SYSIBMADM"."ENV_PROD_INFO" ("INSTALLED_PROD", "INSTALLED_PROD_FULLNAME", "LICENSE_INSTALLED", "PROD_RELEASE", "LICENSE_TYPE") AS
SELECT  installed_prod, installed_prod_fullname, license_installed,  prod_release, license_type FROM TABLE(SYSPROC.ENV_GET_PROD_INFO_V95()) as t;

CREATE VIEW "SYSIBMADM"."ENV_SYS_INFO" ("OS_NAME", "OS_VERSION", "OS_RELEASE", "HOST_NAME", "TOTAL_CPUS", "CONFIGURED_CPUS", "TOTAL_MEMORY") AS
SELECT  os_name, os_version, os_release, host_name, total_cpus,  configured_cpus, total_memory FROM TABLE(SYSPROC.ENV_GET_SYS_INFO()) as t;

CREATE VIEW "SYSIBMADM"."ENV_SYS_RESOURCES" ("NAME", "VALUE", "DATATYPE", "UNIT", "DBPARTITIONNUM") AS
SELECT  name, value, datatype, unit, dbpartitionnum FROM TABLE(SYSPROC.ENV_GET_SYS_RESOURCES()) as t;

CREATE VIEW "SYSIBMADM"."SNAPLOCK" ("SNAPSHOT_TIMESTAMP", "AGENT_ID", "TAB_FILE_ID", "LOCK_OBJECT_TYPE", "LOCK_MODE", "LOCK_STATUS", "LOCK_ESCALATION", "TABNAME", "TABSCHEMA", "TBSP_NAME", "LOCK_ATTRIBUTES", "LOCK_COUNT", "LOCK_CURRENT_MODE", "LOCK_HOLD_COUNT", "LOCK_NAME", "LOCK_RELEASE_FLAGS", "DATA_PARTITION_ID", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, agent_id, tab_file_id, lock_object_type, lock_mode,  lock_status, lock_escalation, tabname, tabschema, tbsp_name,  lock_attributes, lock_count, lock_current_mode, lock_hold_count, lock_name,  lock_release_flags, data_partition_id, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_LOCK ('')) as t;

CREATE VIEW "SYSIBMADM"."LOCKS_HELD" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "APPL_NAME", "AUTHID", "TBSP_NAME", "TABSCHEMA", "TABNAME", "TAB_FILE_ID", "LOCK_OBJECT_TYPE", "LOCK_NAME", "LOCK_MODE", "LOCK_STATUS", "LOCK_ESCALATION", "DBPARTITIONNUM") AS
SELECT  S.SNAPSHOT_TIMESTAMP, A.DB_NAME, S.AGENT_ID, A.APPL_NAME, A.PRIMARY_AUTH_ID, S.TBSP_NAME, S.TABSCHEMA, S.TABNAME, S.TAB_FILE_ID, S.LOCK_OBJECT_TYPE, S.LOCK_NAME, S.LOCK_MODE, S.LOCK_STATUS, S.LOCK_ESCALATION, S.DBPARTITIONNUM FROM SYSIBMADM.SNAPLOCK AS S, SYSIBMADM.SNAPAPPL_INFO AS A WHERE S.AGENT_ID = A.AGENT_ID AND S.DBPARTITIONNUM = A.DBPARTITIONNUM;

CREATE VIEW "SYSIBMADM"."SNAPLOCKWAIT" ("SNAPSHOT_TIMESTAMP", "AGENT_ID", "SUBSECTION_NUMBER", "LOCK_MODE", "LOCK_OBJECT_TYPE", "AGENT_ID_HOLDING_LK", "LOCK_WAIT_START_TIME", "LOCK_MODE_REQUESTED", "LOCK_ESCALATION", "TABNAME", "TABSCHEMA", "TBSP_NAME", "APPL_ID_HOLDING_LK", "LOCK_ATTRIBUTES", "LOCK_CURRENT_MODE", "LOCK_NAME", "LOCK_RELEASE_FLAGS", "DATA_PARTITION_ID", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, agent_id, subsection_number, lock_mode,  lock_object_type, agent_id_holding_lk, lock_wait_start_time,  lock_mode_requested, lock_escalation, tabname, tabschema, tbsp_name,  appl_id_holding_lk, lock_attributes, lock_current_mode, lock_name,  lock_release_flags, data_partition_id, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_LOCKWAIT ('')) as t;

CREATE VIEW "SYSIBMADM"."LOCKWAITS" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "APPL_NAME", "AUTHID", "TBSP_NAME", "TABSCHEMA", "TABNAME", "SUBSECTION_NUMBER", "LOCK_OBJECT_TYPE", "LOCK_WAIT_START_TIME", "LOCK_NAME", "LOCK_MODE", "LOCK_MODE_REQUESTED", "AGENT_ID_HOLDING_LK", "APPL_ID_HOLDING_LK", "LOCK_ESCALATION", "DBPARTITIONNUM") AS
SELECT  S.SNAPSHOT_TIMESTAMP, A.DB_NAME, S.AGENT_ID, A.APPL_NAME, A.PRIMARY_AUTH_ID, S.TBSP_NAME, S.TABSCHEMA, S.TABNAME, S.SUBSECTION_NUMBER, S.LOCK_OBJECT_TYPE, S.LOCK_WAIT_START_TIME, S.LOCK_NAME, S.LOCK_MODE, S.LOCK_MODE_REQUESTED, S.AGENT_ID_HOLDING_LK, S.APPL_ID_HOLDING_LK, S.LOCK_ESCALATION, S.DBPARTITIONNUM FROM SYSIBMADM.SNAPLOCKWAIT AS S, SYSIBMADM.SNAPAPPL_INFO AS A WHERE S.AGENT_ID = A.AGENT_ID AND S.DBPARTITIONNUM = A.DBPARTITIONNUM;

CREATE VIEW "SYSIBMADM"."SNAPDB" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "DB_PATH", "INPUT_DB_ALIAS", "DB_STATUS", "CATALOG_PARTITION", "CATALOG_PARTITION_NAME", "SERVER_PLATFORM", "DB_LOCATION", "DB_CONN_TIME", "LAST_RESET", "LAST_BACKUP", "CONNECTIONS_TOP", "TOTAL_CONS", "TOTAL_SEC_CONS", "APPLS_CUR_CONS", "APPLS_IN_DB2", "NUM_ASSOC_AGENTS", "AGENTS_TOP", "COORD_AGENTS_TOP", "LOCKS_HELD", "LOCK_WAITS", "LOCK_WAIT_TIME", "LOCK_LIST_IN_USE", "DEADLOCKS", "LOCK_ESCALS", "X_LOCK_ESCALS", "LOCKS_WAITING", "LOCK_TIMEOUTS", "NUM_INDOUBT_TRANS", "SORT_HEAP_ALLOCATED", "SORT_SHRHEAP_ALLOCATED", "SORT_SHRHEAP_TOP", "POST_SHRTHRESHOLD_SORTS", "TOTAL_SORTS", "TOTAL_SORT_TIME", "SORT_OVERFLOWS", "ACTIVE_SORTS", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_ASYNC_DATA_READS", "POOL_DATA_WRITES", "POOL_ASYNC_DATA_WRITES", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_ASYNC_INDEX_READS", "POOL_INDEX_WRITES", "POOL_ASYNC_INDEX_WRITES", "POOL_XDA_P_READS", "POOL_XDA_L_READS", "POOL_XDA_WRITES", "POOL_ASYNC_XDA_READS", "POOL_ASYNC_XDA_WRITES", "POOL_TEMP_XDA_P_READS", "POOL_TEMP_XDA_L_READS", "POOL_READ_TIME", "POOL_WRITE_TIME", "POOL_ASYNC_READ_TIME", "POOL_ASYNC_WRITE_TIME", "POOL_ASYNC_DATA_READ_REQS", "POOL_ASYNC_INDEX_READ_REQS", "POOL_ASYNC_XDA_READ_REQS", "POOL_NO_VICTIM_BUFFER", "POOL_LSN_GAP_CLNS", "POOL_DRTY_PG_STEAL_CLNS", "POOL_DRTY_PG_THRSH_CLNS", "PREFETCH_WAIT_TIME", "UNREAD_PREFETCH_PAGES", "DIRECT_READS", "DIRECT_WRITES", "DIRECT_READ_REQS", "DIRECT_WRITE_REQS", "DIRECT_READ_TIME", "DIRECT_WRITE_TIME", "FILES_CLOSED", "ELAPSED_EXEC_TIME_S", "ELAPSED_EXEC_TIME_MS", "COMMIT_SQL_STMTS", "ROLLBACK_SQL_STMTS", "DYNAMIC_SQL_STMTS", "STATIC_SQL_STMTS", "FAILED_SQL_STMTS", "SELECT_SQL_STMTS", "UID_SQL_STMTS", "DDL_SQL_STMTS", "INT_AUTO_REBINDS", "INT_ROWS_DELETED", "INT_ROWS_INSERTED", "INT_ROWS_UPDATED", "INT_COMMITS", "INT_ROLLBACKS", "INT_DEADLOCK_ROLLBACKS", "ROWS_DELETED", "ROWS_INSERTED", "ROWS_UPDATED", "ROWS_SELECTED", "ROWS_READ", "BINDS_PRECOMPILES", "TOTAL_LOG_AVAILABLE", "TOTAL_LOG_USED", "SEC_LOG_USED_TOP", "TOT_LOG_USED_TOP", "SEC_LOGS_ALLOCATED", "LOG_READS", "LOG_READ_TIME_S", "LOG_READ_TIME_NS", "LOG_WRITES", "LOG_WRITE_TIME_S", "LOG_WRITE_TIME_NS", "NUM_LOG_WRITE_IO", "NUM_LOG_READ_IO", "NUM_LOG_PART_PAGE_IO", "NUM_LOG_BUFFER_FULL", "NUM_LOG_DATA_FOUND_IN_BUFFER", "APPL_ID_OLDEST_XACT", "LOG_TO_REDO_FOR_RECOVERY", "LOG_HELD_BY_DIRTY_PAGES", "PKG_CACHE_LOOKUPS", "PKG_CACHE_INSERTS", "PKG_CACHE_NUM_OVERFLOWS", "PKG_CACHE_SIZE_TOP", "APPL_SECTION_LOOKUPS", "APPL_SECTION_INSERTS", "CAT_CACHE_LOOKUPS", "CAT_CACHE_INSERTS", "CAT_CACHE_OVERFLOWS", "CAT_CACHE_SIZE_TOP", "PRIV_WORKSPACE_SIZE_TOP", "PRIV_WORKSPACE_NUM_OVERFLOWS", "PRIV_WORKSPACE_SECTION_INSERTS", "PRIV_WORKSPACE_SECTION_LOOKUPS", "SHR_WORKSPACE_SIZE_TOP", "SHR_WORKSPACE_NUM_OVERFLOWS", "SHR_WORKSPACE_SECTION_INSERTS", "SHR_WORKSPACE_SECTION_LOOKUPS", "TOTAL_HASH_JOINS", "TOTAL_HASH_LOOPS", "HASH_JOIN_OVERFLOWS", "HASH_JOIN_SMALL_OVERFLOWS", "POST_SHRTHRESHOLD_HASH_JOINS", "ACTIVE_HASH_JOINS", "NUM_DB_STORAGE_PATHS", "DBPARTITIONNUM", "SMALLEST_LOG_AVAIL_NODE", "TOTAL_OLAP_FUNCS", "OLAP_FUNC_OVERFLOWS", "ACTIVE_OLAP_FUNCS", "STATS_CACHE_SIZE", "STATS_FABRICATIONS", "SYNC_RUNSTATS", "ASYNC_RUNSTATS", "STATS_FABRICATE_TIME", "SYNC_RUNSTATS_TIME", "NUM_THRESHOLD_VIOLATIONS") AS
SELECT  snapshot_timestamp, db_name, db_path, input_db_alias, db_status, catalog_partition,  catalog_partition_name, server_platform, db_location, db_conn_time, last_reset,  last_backup, connections_top, total_cons, total_sec_cons, appls_cur_cons,  appls_in_db2, num_assoc_agents, agents_top, coord_agents_top, locks_held, lock_waits,  lock_wait_time, lock_list_in_use, deadlocks, lock_escals, x_lock_escals, locks_waiting,  lock_timeouts, num_indoubt_trans, sort_heap_allocated, sort_shrheap_allocated,  sort_shrheap_top, post_shrthreshold_sorts, total_sorts, total_sort_time, sort_overflows, active_sorts,  pool_data_l_reads, pool_data_p_reads, pool_temp_data_l_reads, pool_temp_data_p_reads,  pool_async_data_reads, pool_data_writes, pool_async_data_writes, pool_index_l_reads,  pool_index_p_reads, pool_temp_index_l_reads, pool_temp_index_p_reads,  pool_async_index_reads, pool_index_writes, pool_async_index_writes, pool_xda_p_reads,  pool_xda_l_reads, pool_xda_writes, pool_async_xda_reads, pool_async_xda_writes,  pool_temp_xda_p_reads, pool_temp_xda_l_reads, pool_read_time, pool_write_time,  pool_async_read_time, pool_async_write_time, pool_async_data_read_reqs, pool_async_index_read_reqs,  pool_async_xda_read_reqs, pool_no_victim_buffer, pool_lsn_gap_clns, pool_drty_pg_steal_clns,  pool_drty_pg_thrsh_clns, prefetch_wait_time, unread_prefetch_pages, direct_reads, direct_writes,  direct_read_reqs, direct_write_reqs, direct_read_time, direct_write_time, files_closed,  elapsed_exec_time_s, elapsed_exec_time_ms,  commit_sql_stmts, rollback_sql_stmts, dynamic_sql_stmts, static_sql_stmts, failed_sql_stmts,  select_sql_stmts, uid_sql_stmts, ddl_sql_stmts, int_auto_rebinds, int_rows_deleted,  int_rows_inserted, int_rows_updated, int_commits, int_rollbacks, int_deadlock_rollbacks,  rows_deleted, rows_inserted, rows_updated, rows_selected, rows_read, binds_precompiles,  total_log_available, total_log_used, sec_log_used_top, tot_log_used_top, sec_logs_allocated,  log_reads, log_read_time_s, log_read_time_ns, log_writes, log_write_time_s, log_write_time_ns,  num_log_write_io, num_log_read_io, num_log_part_page_io, num_log_buffer_full,  num_log_data_found_in_buffer, appl_id_oldest_xact, log_to_redo_for_recovery,  log_held_by_dirty_pages, pkg_cache_lookups, pkg_cache_inserts, pkg_cache_num_overflows,  pkg_cache_size_top, appl_section_lookups, appl_section_inserts, cat_cache_lookups,  cat_cache_inserts, cat_cache_overflows, cat_cache_size_top, priv_workspace_size_top,  priv_workspace_num_overflows, priv_workspace_section_inserts, priv_workspace_section_lookups,  shr_workspace_size_top, shr_workspace_num_overflows, shr_workspace_section_inserts,  shr_workspace_section_lookups, total_hash_joins, total_hash_loops, hash_join_overflows,  hash_join_small_overflows, post_shrthreshold_hash_joins, active_hash_joins, num_db_storage_paths,  dbpartitionnum, smallest_log_avail_node, total_olap_funcs, olap_func_overflows, active_olap_funcs,  stats_cache_size, stats_fabrications, sync_runstats, async_runstats, stats_fabricate_time, sync_runstats_time,  num_threshold_violations FROM TABLE(SYSPROC.SNAP_GET_DB_V97(' ')) as dbsnap;

CREATE VIEW "SYSIBMADM"."LOG_UTILIZATION" ("DB_NAME", "LOG_UTILIZATION_PERCENT", "TOTAL_LOG_USED_KB", "TOTAL_LOG_AVAILABLE_KB", "TOTAL_LOG_USED_TOP_KB", "DBPARTITIONNUM") AS
SELECT  DB_NAME,  CASE (TOTAL_LOG_AVAILABLE)   WHEN -1 THEN DEC(-1,5,2)   ELSE DEC(100 * (FLOAT(TOTAL_LOG_USED)/FLOAT(TOTAL_LOG_USED + TOTAL_LOG_AVAILABLE)), 5,2) END, TOTAL_LOG_USED / 1024,  CASE (TOTAL_LOG_AVAILABLE)   WHEN -1 THEN -1   ELSE TOTAL_LOG_AVAILABLE / 1024  END, TOT_LOG_USED_TOP / 1024, DBPARTITIONNUM FROM SYSIBMADM.SNAPDB;

CREATE VIEW "SYSIBMADM"."SNAPSTMT" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "ROWS_READ", "ROWS_WRITTEN", "NUM_AGENTS", "AGENTS_TOP", "STMT_TYPE", "STMT_OPERATION", "SECTION_NUMBER", "QUERY_COST_ESTIMATE", "QUERY_CARD_ESTIMATE", "DEGREE_PARALLELISM", "STMT_SORTS", "TOTAL_SORT_TIME", "SORT_OVERFLOWS", "INT_ROWS_DELETED", "INT_ROWS_UPDATED", "INT_ROWS_INSERTED", "FETCH_COUNT", "STMT_START", "STMT_STOP", "STMT_USR_CPU_TIME_S", "STMT_USR_CPU_TIME_MS", "STMT_SYS_CPU_TIME_S", "STMT_SYS_CPU_TIME_MS", "STMT_ELAPSED_TIME_S", "STMT_ELAPSED_TIME_MS", "BLOCKING_CURSOR", "STMT_NODE_NUMBER", "CURSOR_NAME", "CREATOR", "PACKAGE_NAME", "STMT_TEXT", "CONSISTENCY_TOKEN", "PACKAGE_VERSION_ID", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_XDA_L_READS", "POOL_XDA_P_READS", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_TEMP_XDA_L_READS", "POOL_TEMP_XDA_P_READS", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, agent_id, rows_read, rows_written, num_agents,  agents_top, stmt_type, stmt_operation, section_number, query_cost_estimate,  query_card_estimate, degree_parallelism, stmt_sorts, total_sort_time,  sort_overflows, int_rows_deleted, int_rows_updated, int_rows_inserted,  fetch_count, stmt_start, stmt_stop, stmt_usr_cpu_time_s, stmt_usr_cpu_time_ms,  stmt_sys_cpu_time_s, stmt_sys_cpu_time_ms, stmt_elapsed_time_s,  stmt_elapsed_time_ms, blocking_cursor, stmt_node_number, cursor_name, creator,  package_name, stmt_text, consistency_token, package_version_id,  pool_data_l_reads, pool_data_p_reads, pool_index_l_reads, pool_index_p_reads,  pool_xda_l_reads, pool_xda_p_reads, pool_temp_data_l_reads,  pool_temp_data_p_reads, pool_temp_index_l_reads, pool_temp_index_p_reads,  pool_temp_xda_l_reads, pool_temp_xda_p_reads, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_STMT (' ')) as t;

CREATE VIEW "SYSIBMADM"."LONG_RUNNING_SQL" ("SNAPSHOT_TIMESTAMP", "ELAPSED_TIME_MIN", "AGENT_ID", "APPL_NAME", "APPL_STATUS", "AUTHID", "INBOUND_COMM_ADDRESS", "STMT_TEXT", "DBPARTITIONNUM") AS
SELECT  AI.SNAPSHOT_TIMESTAMP,  CASE WHEN ST.STMT_STOP IS NULL   THEN ( (JULIAN_DAY(CURRENT TIMESTAMP) - JULIAN_DAY(ST.STMT_START)) * 24       + (HOUR(CURRENT TIMESTAMP)       - HOUR(ST.STMT_START))) * 60       + (MINUTE(CURRENT TIMESTAMP)     - MINUTE(ST.STMT_START))  ELSE INT(ST.STMT_ELAPSED_TIME_S/60) END, AI.AGENT_ID, AI.APPL_NAME, AI.APPL_STATUS, AI.PRIMARY_AUTH_ID,  AP.INBOUND_COMM_ADDRESS, ST.STMT_TEXT, AI.DBPARTITIONNUM FROM SYSIBMADM.SNAPSTMT ST, SYSIBMADM.SNAPAPPL_INFO AI, SYSIBMADM.SNAPAPPL AP WHERE ST.AGENT_ID = AI.AGENT_ID AND AI.AGENT_ID = AP.AGENT_ID AND ST.DBPARTITIONNUM = AI.DBPARTITIONNUM AND AI.DBPARTITIONNUM = AP.DBPARTITIONNUM;

CREATE VIEW "SYSIBMADM"."MON_BP_UTILIZATION" ("BP_NAME", "MEMBER", "DATA_PHYSICAL_READS", "DATA_HIT_RATIO_PERCENT", "INDEX_PHYSICAL_READS", "INDEX_HIT_RATIO_PERCENT", "XDA_PHYSICAL_READS", "XDA_HIT_RATIO_PERCENT", "TOTAL_PHYSICAL_READS", "AVG_PHYSICAL_READ_TIME", "PREFETCH_RATIO_PERCENT", "ASYNC_NOT_READ_PERCENT", "TOTAL_WRITES", "AVG_WRITE_TIME", "SYNC_WRITES_PERCENT", "AVG_SYNC_READ_TIME", "AVG_ASYNC_READ_TIME", "AVG_SYNC_WRITE_TIME", "AVG_ASYNC_WRITE_TIME") AS
WITH BP_DATA AS (SELECT BP_NAME, MEMBER, (POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS) AS DATA_LOGICAL_READS, (POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS) AS INDEX_LOGICAL_READS, (POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS XDA_LOGICAL_READS, (POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS) AS DATA_PHYSICAL_READS, (POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS) AS INDEX_PHYSICAL_READS, (POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS XDA_PHYSICAL_READS, (POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS TOTAL_PHYSICAL_READS, (POOL_ASYNC_DATA_READS + POOL_ASYNC_INDEX_READS + POOL_ASYNC_XDA_READS) AS TOTAL_ASYNC_READS, POOL_READ_TIME, UNREAD_PREFETCH_PAGES, (POOL_DATA_WRITES + POOL_INDEX_WRITES + POOL_XDA_WRITES) AS TOTAL_WRITES, (POOL_ASYNC_DATA_WRITES + POOL_ASYNC_INDEX_WRITES + POOL_ASYNC_XDA_WRITES) AS TOTAL_ASYNC_WRITES, POOL_WRITE_TIME, POOL_ASYNC_READ_TIME, POOL_ASYNC_WRITE_TIME FROM TABLE(MON_GET_BUFFERPOOL(NULL, -2))) SELECT BP_NAME, MEMBER, DATA_PHYSICAL_READS, CASE WHEN DATA_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(DATA_PHYSICAL_READS) / FLOAT(DATA_LOGICAL_READS))) * 100, 5, 2) ELSE NULL END AS DATA_HIT_RATIO_PERCENT, INDEX_PHYSICAL_READS, CASE WHEN INDEX_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(INDEX_PHYSICAL_READS) / FLOAT(INDEX_LOGICAL_READS))) * 100, 5, 2) ELSE NULL END AS INDEX_HIT_RATIO_PERCENT, XDA_PHYSICAL_READS, CASE WHEN XDA_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(XDA_PHYSICAL_READS) / FLOAT(XDA_LOGICAL_READS))) * 100, 5, 2) ELSE NULL END AS XDA_HIT_RATIO_PERCENT, TOTAL_PHYSICAL_READS, CASE WHEN TOTAL_PHYSICAL_READS > 0 THEN POOL_READ_TIME / TOTAL_PHYSICAL_READS ELSE NULL END AS AVG_PHYSICAL_READ_TIME, CASE WHEN TOTAL_PHYSICAL_READS > 0 THEN DEC(100 * FLOAT(TOTAL_ASYNC_READS) / FLOAT(TOTAL_PHYSICAL_READS), 5, 2) ELSE NULL END AS PREFETCH_RATIO_PERCENT, CASE WHEN TOTAL_ASYNC_READS > 0 THEN DEC(100 * FLOAT(UNREAD_PREFETCH_PAGES) / FLOAT(TOTAL_ASYNC_READS), 5, 2) ELSE NULL END AS ASYNC_NOT_READ_PERCENT, TOTAL_WRITES, CASE WHEN TOTAL_WRITES > 0 THEN POOL_WRITE_TIME / TOTAL_WRITES ELSE NULL END AS AVG_WRITE_TIME, CASE WHEN TOTAL_WRITES > 0 THEN DEC((FLOAT(TOTAL_WRITES - TOTAL_ASYNC_WRITES) / FLOAT(TOTAL_WRITES)) * 100, 5, 2) ELSE NULL END AS SYNC_WRITES_PERCENT, CASE WHEN (TOTAL_PHYSICAL_READS - TOTAL_ASYNC_READS) > 0 THEN (POOL_READ_TIME - POOL_ASYNC_READ_TIME) / (TOTAL_PHYSICAL_READS - TOTAL_ASYNC_READS) ELSE NULL END AS AVG_SYNC_READ_TIME, CASE WHEN TOTAL_ASYNC_READS > 0 THEN POOL_ASYNC_READ_TIME / TOTAL_ASYNC_READS ELSE NULL END AS AVG_ASYNC_READ_TIME, CASE WHEN (TOTAL_WRITES - TOTAL_ASYNC_WRITES) > 0 THEN (POOL_WRITE_TIME - POOL_ASYNC_WRITE_TIME) / (TOTAL_WRITES - TOTAL_ASYNC_WRITES) ELSE NULL END AS AVG_SYNC_WRITE_TIME, CASE WHEN TOTAL_ASYNC_WRITES > 0 THEN POOL_ASYNC_WRITE_TIME / TOTAL_ASYNC_WRITES ELSE NULL END AS AVG_ASYNC_WRITE_TIME FROM BP_DATA;

CREATE VIEW "SYSIBMADM"."MON_CONNECTION_SUMMARY" ("APPLICATION_HANDLE", "APPLICATION_NAME", "APPLICATION_ID", "SESSION_AUTH_ID", "TOTAL_APP_COMMITS", "TOTAL_APP_ROLLBACKS", "ACT_COMPLETED_TOTAL", "APP_RQSTS_COMPLETED_TOTAL", "AVG_RQST_CPU_TIME", "ROUTINE_TIME_RQST_PERCENT", "RQST_WAIT_TIME_PERCENT", "ACT_WAIT_TIME_PERCENT", "IO_WAIT_TIME_PERCENT", "LOCK_WAIT_TIME_PERCENT", "AGENT_WAIT_TIME_PERCENT", "NETWORK_WAIT_TIME_PERCENT", "SECTION_PROC_TIME_PERCENT", "SECTION_SORT_PROC_TIME_PERCENT", "COMPILE_PROC_TIME_PERCENT", "TRANSACT_END_PROC_TIME_PERCENT", "UTILS_PROC_TIME_PERCENT", "AVG_LOCK_WAITS_PER_ACT", "AVG_LOCK_TIMEOUTS_PER_ACT", "AVG_DEADLOCKS_PER_ACT", "AVG_LOCK_ESCALS_PER_ACT", "ROWS_READ_PER_ROWS_RETURNED", "TOTAL_BP_HIT_RATIO_PERCENT") AS
WITH METRICS AS (SELECT APPLICATION_HANDLE, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_COMPLETED_TOTAL + ACT_ABORTED_TOTAL) AS ACT_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(TCPIP_SEND_WAIT_TIME + TCPIP_RECV_WAIT_TIME + IPC_SEND_WAIT_TIME + IPC_RECV_WAIT_TIME) AS NETWORK_WAIT_TIME, SUM(TOTAL_RQST_TIME - TOTAL_WAIT_TIME) AS PROC_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME + TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME + TOTAL_ROLLBACK_PROC_TIME) AS TRANSACT_END_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME + TOTAL_REORG_PROC_TIME + TOTAL_LOAD_PROC_TIME) AS UTILS_PROC_TIME, SUM(POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS + POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS + POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS L_READS, SUM(POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS P_READS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME FROM TABLE(MON_GET_CONNECTION(NULL, -2)) GROUP BY APPLICATION_HANDLE) SELECT C.APPLICATION_HANDLE, C.APPLICATION_NAME, C.APPLICATION_ID, C.SESSION_AUTH_ID, M.TOTAL_APP_COMMITS, M.TOTAL_APP_ROLLBACKS, M.ACT_COMPLETED_TOTAL, M.APP_RQSTS_COMPLETED_TOTAL, CASE WHEN M.APP_RQSTS_COMPLETED_TOTAL > 0 THEN (M.TOTAL_CPU_TIME / M.APP_RQSTS_COMPLETED_TOTAL) ELSE NULL END AS AVG_RQST_CPU_TIME, CASE WHEN M.TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(M.TOTAL_ROUTINE_TIME) / FLOAT(M.TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS ROUTINE_TIME_RQST_PERCENT, CASE WHEN M.TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(M.TOTAL_WAIT_TIME) / FLOAT(M.TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS RQST_WAIT_TIME_PERCENT, CASE WHEN M.TOTAL_ACT_TIME > 0 THEN DEC(FLOAT(M.TOTAL_ACT_WAIT_TIME) / FLOAT(M.TOTAL_ACT_TIME) * 100, 5, 2) ELSE NULL END AS ACT_WAIT_TIME_PERCENT, CASE WHEN M.TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(M.IO_WAIT_TIME) / FLOAT(M.TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS IO_WAIT_TIME_PERCENT, CASE WHEN M.TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(M.LOCK_WAIT_TIME) / FLOAT(M.TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS LOCK_WAIT_TIME_PERCENT, CASE WHEN M.TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(M.AGENT_WAIT_TIME) / FLOAT(M.TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS AGENT_WAIT_TIME_PERCENT, CASE WHEN M.TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(M.NETWORK_WAIT_TIME) / FLOAT(M.TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS NETWORK_WAIT_TIME_PERCENT, CASE WHEN M.PROC_TIME > 0 THEN DEC(FLOAT(M.SECTION_PROC_TIME) / FLOAT(M.PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_PROC_TIME_PERCENT, CASE WHEN M.PROC_TIME > 0 THEN DEC(FLOAT(M.SECTION_SORT_PROC_TIME) / FLOAT(M.PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_SORT_PROC_TIME_PERCENT, CASE WHEN M.PROC_TIME > 0 THEN DEC(FLOAT(M.COMPILE_PROC_TIME) / FLOAT(M.PROC_TIME) * 100, 5, 2) ELSE NULL END AS COMPILE_PROC_TIME_PERCENT, CASE WHEN M.PROC_TIME > 0 THEN DEC(FLOAT(M.TRANSACT_END_PROC_TIME) / FLOAT(M.PROC_TIME) * 100, 5, 2) ELSE NULL END AS TRANSACT_END_PROC_TIME_PERCENT, CASE WHEN M.PROC_TIME > 0 THEN DEC(FLOAT(M.UTILS_PROC_TIME) / FLOAT(M.PROC_TIME) * 100, 5, 2) ELSE NULL END AS UTILS_PROC_TIME_PERCENT, CASE WHEN M.ACT_TOTAL > 0 THEN M.LOCK_WAITS / M.ACT_TOTAL ELSE NULL END AS AVG_LOCK_WAITS_PER_ACT, CASE WHEN M.ACT_TOTAL > 0 THEN M.LOCK_TIMEOUTS / M.ACT_TOTAL ELSE NULL END AS AVG_LOCK_TIMEOUTS_PER_ACT, CASE WHEN M.ACT_TOTAL > 0 THEN M.DEADLOCKS / M.ACT_TOTAL ELSE NULL END AS AVG_DEADLOCKS_PER_ACT, CASE WHEN M.ACT_TOTAL > 0 THEN M.LOCK_ESCALS / M.ACT_TOTAL ELSE NULL END AS AVG_LOCK_ESCALS_PER_ACT, CASE WHEN M.ROWS_RETURNED > 0 THEN M.ROWS_READ / M.ROWS_RETURNED ELSE NULL END AS ROWS_READ_PER_ROWS_RETURNED, CASE WHEN M.L_READS > 0 THEN DEC((1 - (FLOAT(M.P_READS) / FLOAT(M.L_READS))) * 100, 5, 2) ELSE NULL END AS TOTAL_BP_HIT_RATIO_PERCENT FROM TABLE(MON_GET_CONNECTION(NULL, -2)) AS C JOIN METRICS AS M ON C.APPLICATION_HANDLE = M.APPLICATION_HANDLE WHERE C.MEMBER = C.COORD_MEMBER;

CREATE VIEW "SYSIBMADM"."MON_CURRENT_SQL" ("COORD_MEMBER", "APPLICATION_HANDLE", "APPLICATION_NAME", "SESSION_AUTH_ID", "CLIENT_APPLNAME", "ELAPSED_TIME_SEC", "ACTIVITY_STATE", "ACTIVITY_TYPE", "TOTAL_CPU_TIME", "ROWS_READ", "ROWS_RETURNED", "QUERY_COST_ESTIMATE", "DIRECT_READS", "DIRECT_WRITES", "STMT_TEXT") AS
WITH WLM_METRICS AS (SELECT APPLICATION_HANDLE, UOW_ID, ACTIVITY_ID, MIN(COORD_PARTITION_NUM) AS COORD_MEMBER, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(DIRECT_READS) AS DIRECT_READS, SUM(DIRECT_WRITES) AS DIRECT_WRITES FROM TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(NULL, -2)) GROUP BY APPLICATION_HANDLE, UOW_ID, ACTIVITY_ID ) SELECT M.COORD_MEMBER AS COORD_MEMBER, W.APPLICATION_HANDLE AS APPLICATION_HANDLE, C.APPLICATION_NAME AS APPLICATION_NAME, C.SESSION_AUTH_ID AS SESSION_AUTH_ID, C.CLIENT_APPLNAME AS CLIENT_APPLNAME, ((  (JULIAN_DAY(CURRENT TIMESTAMP) - JULIAN_DAY(W.LOCAL_START_TIME)) * 24  + (HOUR(CURRENT TIMESTAMP)       - HOUR(W.LOCAL_START_TIME))) * 60  + (MINUTE(CURRENT TIMESTAMP)     - MINUTE(W.LOCAL_START_TIME))) * 60  + (SECOND(CURRENT TIMESTAMP)     - SECOND(W.LOCAL_START_TIME))  AS ELAPSED_TIME_SEC,W.ACTIVITY_STATE as ACTIVITY_STATE, W.ACTIVITY_TYPE as ACTIVITY_TYPE, M.TOTAL_CPU_TIME AS TOTAL_CPU_TIME, M.ROWS_READ AS ROWS_READ, M.ROWS_RETURNED AS ROWS_RETURNED, W.QUERY_COST_ESTIMATE AS QUERY_COST_ESTIMATE, M.DIRECT_READS AS DIRECT_READS, M.DIRECT_WRITES AS DIRECT_WRITES, P.STMT_TEXT AS STMT_TEXT FROM WLM_METRICS AS M JOIN TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(NULL, -2)) AS W ON W.APPLICATION_HANDLE = M.APPLICATION_HANDLE AND W.DBPARTITIONNUM = M.COORD_MEMBER AND W.UOW_ID = M.UOW_ID AND W.ACTIVITY_ID = M.ACTIVITY_ID JOIN TABLE(MON_GET_CONNECTION(NULL, -2)) AS C ON C.APPLICATION_HANDLE = M.APPLICATION_HANDLE AND C.MEMBER = M.COORD_MEMBER JOIN TABLE(MON_GET_PKG_CACHE_STMT(NULL, NULL, NULL, -2)) AS P ON P.EXECUTABLE_ID = W.EXECUTABLE_ID AND P.MEMBER = M.COORD_MEMBER;

CREATE VIEW "SYSIBMADM"."MON_CURRENT_UOW" ("COORD_MEMBER", "UOW_ID", "APPLICATION_HANDLE", "APPLICATION_NAME", "SESSION_AUTH_ID", "CLIENT_APPLNAME", "ELAPSED_TIME_SEC", "WORKLOAD_OCCURRENCE_STATE", "TOTAL_CPU_TIME", "TOTAL_ROWS_MODIFIED", "TOTAL_ROWS_READ", "TOTAL_ROWS_RETURNED") AS
WITH UOW_METRICS AS (SELECT APPLICATION_HANDLE, MIN(COORD_MEMBER) AS COORD_MEMBER, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_MODIFIED) AS TOTAL_ROWS_MODIFIED, SUM(ROWS_READ) AS TOTAL_ROWS_READ, SUM(ROWS_RETURNED) AS TOTAL_ROWS_RETURNED FROM TABLE(MON_GET_UNIT_OF_WORK(NULL, -2)) GROUP BY APPLICATION_HANDLE) SELECT M.COORD_MEMBER AS COORD_MEMBER, U.UOW_ID AS UOW_ID, M.APPLICATION_HANDLE AS APPLICATION_HANDLE, C.APPLICATION_NAME AS APPLICATION_NAME, U.SESSION_AUTH_ID AS SESSION_AUTH_ID, U.CLIENT_APPLNAME AS CLIENT_APPLNAME, ((  (JULIAN_DAY(CURRENT TIMESTAMP) - JULIAN_DAY(U.UOW_START_TIME)) * 24  + (HOUR(CURRENT TIMESTAMP)       - HOUR(U.UOW_START_TIME))) * 60  + (MINUTE(CURRENT TIMESTAMP)     - MINUTE(U.UOW_START_TIME))) * 60  + (SECOND(CURRENT TIMESTAMP)     - SECOND(U.UOW_START_TIME))  AS ELAPSED_TIME_SEC,U.WORKLOAD_OCCURRENCE_STATE as WORKLOAD_OCCURRENCE_STATE, M.TOTAL_CPU_TIME AS TOTAL_CPU_TIME, M.TOTAL_ROWS_MODIFIED AS TOTAL_ROWS_MODIFIED, M.TOTAL_ROWS_READ AS TOTAL_ROWS_READ, M.TOTAL_ROWS_RETURNED AS TOTAL_ROWS_RETURNED FROM UOW_METRICS AS M JOIN TABLE(MON_GET_UNIT_OF_WORK(NULL, -2)) AS U ON U.APPLICATION_HANDLE = M.APPLICATION_HANDLE AND U.MEMBER = M.COORD_MEMBER JOIN TABLE(MON_GET_CONNECTION(NULL, -2)) AS C ON C.APPLICATION_HANDLE = M.APPLICATION_HANDLE AND C.MEMBER = M.COORD_MEMBER;

CREATE VIEW "SYSIBMADM"."MON_DB_SUMMARY" ("TOTAL_APP_COMMITS", "TOTAL_APP_ROLLBACKS", "ACT_COMPLETED_TOTAL", "APP_RQSTS_COMPLETED_TOTAL", "AVG_RQST_CPU_TIME", "ROUTINE_TIME_RQST_PERCENT", "RQST_WAIT_TIME_PERCENT", "ACT_WAIT_TIME_PERCENT", "IO_WAIT_TIME_PERCENT", "LOCK_WAIT_TIME_PERCENT", "AGENT_WAIT_TIME_PERCENT", "NETWORK_WAIT_TIME_PERCENT", "SECTION_PROC_TIME_PERCENT", "SECTION_SORT_PROC_TIME_PERCENT", "COMPILE_PROC_TIME_PERCENT", "TRANSACT_END_PROC_TIME_PERCENT", "UTILS_PROC_TIME_PERCENT", "AVG_LOCK_WAITS_PER_ACT", "AVG_LOCK_TIMEOUTS_PER_ACT", "AVG_DEADLOCKS_PER_ACT", "AVG_LOCK_ESCALS_PER_ACT", "ROWS_READ_PER_ROWS_RETURNED", "TOTAL_BP_HIT_RATIO_PERCENT") AS
WITH METRICS AS (SELECT SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_COMPLETED_TOTAL + ACT_ABORTED_TOTAL) AS ACT_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(TCPIP_SEND_WAIT_TIME + TCPIP_RECV_WAIT_TIME + IPC_SEND_WAIT_TIME + IPC_RECV_WAIT_TIME) AS NETWORK_WAIT_TIME, SUM(TOTAL_RQST_TIME - TOTAL_WAIT_TIME) AS PROC_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME + TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME + TOTAL_ROLLBACK_PROC_TIME) AS TRANSACT_END_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME + TOTAL_REORG_PROC_TIME + TOTAL_LOAD_PROC_TIME) AS UTILS_PROC_TIME, SUM(POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS + POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS + POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS L_READS, SUM(POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS P_READS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2))) SELECT TOTAL_APP_COMMITS, TOTAL_APP_ROLLBACKS, ACT_COMPLETED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, CASE WHEN APP_RQSTS_COMPLETED_TOTAL > 0 THEN (TOTAL_CPU_TIME / APP_RQSTS_COMPLETED_TOTAL) ELSE NULL END AS AVG_RQST_CPU_TIME, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_ROUTINE_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS ROUTINE_TIME_RQST_PERCENT, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_WAIT_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS RQST_WAIT_TIME_PERCENT, CASE WHEN TOTAL_ACT_TIME > 0 THEN DEC(FLOAT(TOTAL_ACT_WAIT_TIME) / FLOAT(TOTAL_ACT_TIME) * 100, 5, 2) ELSE NULL END AS ACT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(IO_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS IO_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(LOCK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS LOCK_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(AGENT_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS AGENT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(NETWORK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS NETWORK_WAIT_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_SORT_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_SORT_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(COMPILE_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS COMPILE_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(TRANSACT_END_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS TRANSACT_END_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(UTILS_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS UTILS_PROC_TIME_PERCENT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_WAITS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_WAITS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_TIMEOUTS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_TIMEOUTS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN DEADLOCKS / ACT_TOTAL ELSE NULL END AS AVG_DEADLOCKS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_ESCALS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_ESCALS_PER_ACT, CASE WHEN ROWS_RETURNED > 0 THEN ROWS_READ / ROWS_RETURNED ELSE NULL END AS ROWS_READ_PER_ROWS_RETURNED, CASE WHEN L_READS > 0 THEN DEC((1 - (FLOAT(P_READS) / FLOAT(L_READS))) * 100, 5, 2) ELSE NULL END AS TOTAL_BP_HIT_RATIO_PERCENT FROM METRICS;

CREATE VIEW "SYSIBMADM"."MON_LOCKWAITS" ("LOCK_NAME", "LOCK_OBJECT_TYPE", "LOCK_WAIT_ELAPSED_TIME", "TABSCHEMA", "TABNAME", "DATA_PARTITION_ID", "LOCK_MODE", "LOCK_CURRENT_MODE", "LOCK_MODE_REQUESTED", "REQ_APPLICATION_HANDLE", "REQ_AGENT_TID", "REQ_MEMBER", "REQ_APPLICATION_NAME", "REQ_USERID", "REQ_STMT_TEXT", "HLD_APPLICATION_HANDLE", "HLD_MEMBER", "HLD_APPLICATION_NAME", "HLD_USERID", "HLD_CURRENT_STMT_TEXT") AS
SELECT L.LOCK_NAME, L.LOCK_OBJECT_TYPE,        ((  (JULIAN_DAY(CURRENT TIMESTAMP) - JULIAN_DAY(L.LOCK_WAIT_START_TIME)) * 24         + (HOUR(CURRENT TIMESTAMP)       - HOUR(L.LOCK_WAIT_START_TIME))) * 60         + (MINUTE(CURRENT TIMESTAMP)     - MINUTE(L.LOCK_WAIT_START_TIME))) * 60         + (SECOND(CURRENT TIMESTAMP)     - SECOND(L.LOCK_WAIT_START_TIME))         AS LOCK_WAIT_ELAPSED_TIME,       CASE            WHEN L.TBSP_ID > 0 THEN T.TABSCHEMA           ELSE S.TABSCHEMA        END,        CASE           WHEN L.TBSP_ID > 0 THEN T.TABNAME           ELSE S.TABNAME        END,        CASE           WHEN L.TBSP_ID > 0 THEN T.DATA_PARTITION_ID           ELSE -1        END,        L.LOCK_MODE, L.LOCK_CURRENT_MODE, L.LOCK_MODE_REQUESTED,        L.REQ_APPLICATION_HANDLE, L.REQ_AGENT_TID,        L.REQ_MEMBER, REQ_C.APPLICATION_NAME AS REQ_APPLICATION_NAME,        REQ_C.SESSION_AUTH_ID AS REQ_USERID,        REQ_P.STMT_TEXT AS REQ_STMT_TEXT,        L.HLD_APPLICATION_HANDLE, L.HLD_MEMBER,        HLD_D.APPLICATION_NAME AS HLD_APPLICATION_NAME,        HLD_D.SESSION_AUTH_ID AS HLD_USERID,        HLD_P.STMT_TEXT AS HLD_CURRENT_STMT_TEXT FROM TABLE( MON_GET_APPL_LOCKWAIT( NULL, -2 )) AS L LEFT OUTER JOIN    TABLE( MON_GET_CONNECTION( L.HLD_APPLICATION_HANDLE, L.HLD_MEMBER )         ) AS HLD_D    ON L.HLD_MEMBER             = HLD_D.MEMBER AND       L.HLD_APPLICATION_HANDLE = HLD_D.APPLICATION_HANDLE AND       L.HLD_APPLICATION_HANDLE IS NOT NULL LEFT OUTER JOIN    TABLE( WLM_GET_SERVICE_CLASS_AGENTS_V97( NULL, NULL,                                             L.HLD_APPLICATION_HANDLE,                                             HLD_D.COORD_MEMBER )         ) AS HLD_A    ON L.HLD_APPLICATION_HANDLE = HLD_A.APPLICATION_HANDLE AND       HLD_A.AGENT_TYPE         = 'COORDINATOR' AND       L.HLD_APPLICATION_HANDLE IS NOT NULL LEFT OUTER JOIN    TABLE( WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97( L.HLD_APPLICATION_HANDLE,                                                       HLD_D.COORD_MEMBER )         ) AS HLD_ACT     ON HLD_A.APPLICATION_HANDLE = HLD_ACT.APPLICATION_HANDLE AND        HLD_A.UOW_ID             = HLD_ACT.UOW_ID AND        HLD_A.ACTIVITY_ID        = HLD_ACT.ACTIVITY_ID AND        HLD_A.APPLICATION_HANDLE IS NOT NULL LEFT OUTER JOIN    TABLE( MON_GET_PKG_CACHE_STMT( NULL, HLD_ACT.EXECUTABLE_ID,                                   NULL, HLD_D.COORD_MEMBER )         ) AS HLD_P    ON HLD_D.COORD_MEMBER     = HLD_P.MEMBER AND       HLD_ACT.EXECUTABLE_ID  = HLD_P.EXECUTABLE_ID AND       HLD_ACT.EXECUTABLE_ID IS NOT NULL AND       L.HLD_APPLICATION_HANDLE IS NOT NULL LEFT OUTER JOIN    TABLE( MON_GET_TABLE( NULL, NULL, L.HLD_MEMBER )) AS T    ON L.TBSP_ID     = T.TBSP_ID AND       L.TAB_FILE_ID = T.TAB_FILE_ID AND       L.HLD_MEMBER  = T.MEMBER AND       L.TBSP_ID IS NOT NULL AND       L.TAB_FILE_ID IS NOT NULL LEFT OUTER JOIN    SYSCAT.TABLES  AS S    ON L.TBSP_ID     = S.TBSPACEID AND       L.TAB_FILE_ID = S.TABLEID AND       L.TBSP_ID IS NOT NULL AND       L.TAB_FILE_ID IS NOT NULL LEFT OUTER JOIN     TABLE( MON_GET_CONNECTION( L.REQ_APPLICATION_HANDLE, L.REQ_MEMBER )         ) AS REQ_C    ON L.REQ_MEMBER = REQ_C.MEMBER AND       L.REQ_APPLICATION_HANDLE = REQ_C.APPLICATION_HANDLE AND       L.REQ_APPLICATION_HANDLE IS NOT NULL LEFT OUTER JOIN    TABLE( MON_GET_PKG_CACHE_STMT( NULL, L.REQ_EXECUTABLE_ID,                                   NULL, L.REQ_MEMBER )         ) AS REQ_P    ON L.REQ_MEMBER        = REQ_P.MEMBER AND       L.REQ_EXECUTABLE_ID = REQ_P.EXECUTABLE_ID AND       L.REQ_EXECUTABLE_ID IS NOT NULL;

CREATE VIEW "SYSIBMADM"."MON_PKG_CACHE_SUMMARY" ("SECTION_TYPE", "EXECUTABLE_ID", "NUM_COORD_EXEC", "NUM_COORD_EXEC_WITH_METRICS", "TOTAL_STMT_EXEC_TIME", "AVG_STMT_EXEC_TIME", "TOTAL_CPU_TIME", "AVG_CPU_TIME", "TOTAL_LOCK_WAIT_TIME", "AVG_LOCK_WAIT_TIME", "TOTAL_IO_WAIT_TIME", "AVG_IO_WAIT_TIME", "PREP_TIME", "ROWS_READ_PER_ROWS_RETURNED", "STMT_TEXT") AS
WITH EXEC_METRICS AS (SELECT EXECUTABLE_ID, MIN(MEMBER) AS MIN_MEMBER, SUM(NUM_COORD_EXEC) AS NUM_COORD_EXEC, SUM(NUM_COORD_EXEC_WITH_METRICS) AS NUM_COORD_EXEC_WITH_METRICS, SUM(STMT_EXEC_TIME) AS TOTAL_STMT_EXEC_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(LOCK_WAIT_TIME) AS TOTAL_LOCK_WAIT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS TOTAL_IO_WAIT_TIME, SUM(PREP_TIME) AS PREP_TIME, SUM(ROWS_READ) AS TOTAL_ROWS_READ, SUM(ROWS_RETURNED) AS TOTAL_ROWS_RETURNED FROM TABLE(MON_GET_PKG_CACHE_STMT (NULL, NULL, NULL, -2)) GROUP BY EXECUTABLE_ID) SELECT P.SECTION_TYPE, P.EXECUTABLE_ID, M.NUM_COORD_EXEC, M.NUM_COORD_EXEC_WITH_METRICS, M.TOTAL_STMT_EXEC_TIME, CASE WHEN M.NUM_COORD_EXEC_WITH_METRICS > 0 THEN M.TOTAL_STMT_EXEC_TIME / M.NUM_COORD_EXEC_WITH_METRICS ELSE NULL END AS AVG_STMT_EXEC_TIME, M.TOTAL_CPU_TIME, CASE WHEN M.NUM_COORD_EXEC_WITH_METRICS > 0 THEN M.TOTAL_CPU_TIME / M.NUM_COORD_EXEC_WITH_METRICS ELSE NULL END AS AVG_CPU_TIME, M.TOTAL_LOCK_WAIT_TIME, CASE WHEN M.NUM_COORD_EXEC_WITH_METRICS > 0 THEN M.TOTAL_LOCK_WAIT_TIME / M.NUM_COORD_EXEC_WITH_METRICS ELSE NULL END AS AVG_LOCK_WAIT_TIME, M.TOTAL_IO_WAIT_TIME, CASE WHEN M.NUM_COORD_EXEC_WITH_METRICS > 0 THEN M.TOTAL_IO_WAIT_TIME / M.NUM_COORD_EXEC_WITH_METRICS ELSE NULL END AS AVG_IO_WAIT_TIME, M.PREP_TIME, CASE WHEN M.TOTAL_ROWS_RETURNED > 0 THEN M.TOTAL_ROWS_READ / M.TOTAL_ROWS_RETURNED ELSE NULL END AS ROWS_READ_PER_ROWS_RETURNED, P.STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT (NULL, NULL, NULL, -2)) AS P JOIN EXEC_METRICS AS M ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER;

CREATE VIEW "SYSIBMADM"."MON_SERVICE_SUBCLASS_SUMMARY" ("SERVICE_SUPERCLASS_NAME", "SERVICE_SUBCLASS_NAME", "SERVICE_CLASS_ID", "TOTAL_APP_COMMITS", "TOTAL_APP_ROLLBACKS", "ACT_COMPLETED_TOTAL", "APP_RQSTS_COMPLETED_TOTAL", "AVG_RQST_CPU_TIME", "ROUTINE_TIME_RQST_PERCENT", "RQST_WAIT_TIME_PERCENT", "ACT_WAIT_TIME_PERCENT", "IO_WAIT_TIME_PERCENT", "LOCK_WAIT_TIME_PERCENT", "AGENT_WAIT_TIME_PERCENT", "NETWORK_WAIT_TIME_PERCENT", "SECTION_PROC_TIME_PERCENT", "SECTION_SORT_PROC_TIME_PERCENT", "COMPILE_PROC_TIME_PERCENT", "TRANSACT_END_PROC_TIME_PERCENT", "UTILS_PROC_TIME_PERCENT", "AVG_LOCK_WAITS_PER_ACT", "AVG_LOCK_TIMEOUTS_PER_ACT", "AVG_DEADLOCKS_PER_ACT", "AVG_LOCK_ESCALS_PER_ACT", "ROWS_READ_PER_ROWS_RETURNED", "TOTAL_BP_HIT_RATIO_PERCENT") AS
WITH METRICS AS (SELECT SERVICE_SUPERCLASS_NAME, SERVICE_SUBCLASS_NAME, SERVICE_CLASS_ID, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_COMPLETED_TOTAL + ACT_ABORTED_TOTAL) AS ACT_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(TCPIP_SEND_WAIT_TIME + TCPIP_RECV_WAIT_TIME + IPC_SEND_WAIT_TIME + IPC_RECV_WAIT_TIME) AS NETWORK_WAIT_TIME, SUM(TOTAL_RQST_TIME - TOTAL_WAIT_TIME) AS PROC_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME + TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME + TOTAL_ROLLBACK_PROC_TIME) AS TRANSACT_END_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME + TOTAL_REORG_PROC_TIME + TOTAL_LOAD_PROC_TIME) AS UTILS_PROC_TIME, SUM(POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS + POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS + POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS L_READS, SUM(POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS P_READS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)) GROUP BY SERVICE_SUPERCLASS_NAME, SERVICE_SUBCLASS_NAME, SERVICE_CLASS_ID) SELECT SERVICE_SUPERCLASS_NAME, SERVICE_SUBCLASS_NAME, SERVICE_CLASS_ID, TOTAL_APP_COMMITS, TOTAL_APP_ROLLBACKS, ACT_COMPLETED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, CASE WHEN APP_RQSTS_COMPLETED_TOTAL > 0 THEN (TOTAL_CPU_TIME / APP_RQSTS_COMPLETED_TOTAL) ELSE NULL END AS AVG_RQST_CPU_TIME, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_ROUTINE_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS ROUTINE_TIME_RQST_PERCENT, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_WAIT_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS RQST_WAIT_TIME_PERCENT, CASE WHEN TOTAL_ACT_TIME > 0 THEN DEC(FLOAT(TOTAL_ACT_WAIT_TIME) / FLOAT(TOTAL_ACT_TIME) * 100, 5, 2) ELSE NULL END AS ACT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(IO_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS IO_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(LOCK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS LOCK_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(AGENT_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS AGENT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(NETWORK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS NETWORK_WAIT_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_SORT_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_SORT_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(COMPILE_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS COMPILE_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(TRANSACT_END_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS TRANSACT_END_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(UTILS_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS UTILS_PROC_TIME_PERCENT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_WAITS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_WAITS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_TIMEOUTS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_TIMEOUTS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN DEADLOCKS / ACT_TOTAL ELSE NULL END AS AVG_DEADLOCKS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_ESCALS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_ESCALS_PER_ACT, CASE WHEN ROWS_RETURNED > 0 THEN ROWS_READ / ROWS_RETURNED ELSE NULL END AS ROWS_READ_PER_ROWS_RETURNED, CASE WHEN L_READS > 0 THEN DEC((1 - (FLOAT(P_READS) / FLOAT(L_READS))) * 100, 5, 2) ELSE NULL END AS TOTAL_BP_HIT_RATIO_PERCENT FROM METRICS;

CREATE VIEW "SYSIBMADM"."MON_TBSP_UTILIZATION" ("TBSP_NAME", "MEMBER", "TBSP_TYPE", "TBSP_CONTENT_TYPE", "TBSP_STATE", "TBSP_PAGE_SIZE", "TBSP_EXTENT_SIZE", "TBSP_PREFETCH_SIZE", "TBSP_USING_AUTO_STORAGE", "TBSP_AUTO_RESIZE_ENABLED", "TBSP_TOTAL_SIZE_KB", "TBSP_USABLE_SIZE_KB", "TBSP_UTILIZATION_PERCENT", "TBSP_PAGE_TOP", "DATA_PHYSICAL_READS", "DATA_HIT_RATIO_PERCENT", "INDEX_PHYSICAL_READS", "INDEX_HIT_RATIO_PERCENT", "XDA_PHYSICAL_READS", "XDA_HIT_RATIO_PERCENT") AS
WITH TBSP_DATA AS (SELECT TBSP_NAME, MEMBER, TBSP_TYPE, TBSP_CONTENT_TYPE, TBSP_STATE, TBSP_PAGE_SIZE, TBSP_EXTENT_SIZE, TBSP_PREFETCH_SIZE, TBSP_USING_AUTO_STORAGE, TBSP_AUTO_RESIZE_ENABLED, (TBSP_TOTAL_PAGES * TBSP_PAGE_SIZE)/1024 AS TBSP_TOTAL_SIZE_KB, (TBSP_USABLE_PAGES * TBSP_PAGE_SIZE)/1024 AS TBSP_USABLE_SIZE_KB, TBSP_USABLE_PAGES, TBSP_USED_PAGES, TBSP_PAGE_TOP, (POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS) AS DATA_LOGICAL_READS, (POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS) AS DATA_PHYSICAL_READS, (POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS) AS INDEX_LOGICAL_READS, (POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS) AS INDEX_PHYSICAL_READS, (POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS XDA_LOGICAL_READS, (POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS XDA_PHYSICAL_READS FROM TABLE(MON_GET_TABLESPACE(NULL, -2))) SELECT TBSP_NAME, MEMBER, TBSP_TYPE, TBSP_CONTENT_TYPE, TBSP_STATE, TBSP_PAGE_SIZE, TBSP_EXTENT_SIZE, TBSP_PREFETCH_SIZE, TBSP_USING_AUTO_STORAGE, TBSP_AUTO_RESIZE_ENABLED, TBSP_TOTAL_SIZE_KB, TBSP_USABLE_SIZE_KB, CASE WHEN TBSP_USABLE_PAGES > 0 THEN DEC((FLOAT(TBSP_USED_PAGES)/FLOAT(TBSP_USABLE_PAGES)) * 100,5,2) ELSE NULL END AS TBSP_UTILIZATION_PERCENT, TBSP_PAGE_TOP, DATA_PHYSICAL_READS, CASE WHEN DATA_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(DATA_PHYSICAL_READS) / FLOAT(DATA_LOGICAL_READS))) * 100,5,2) ELSE NULL END AS DATA_HIT_RATIO_PERCENT, INDEX_PHYSICAL_READS, CASE WHEN INDEX_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(INDEX_PHYSICAL_READS) / FLOAT(INDEX_LOGICAL_READS))) * 100,5,2) ELSE NULL END AS INDEX_HIT_RATIO_PERCENT, XDA_PHYSICAL_READS, CASE WHEN XDA_LOGICAL_READS > 0 THEN DEC((1 - (FLOAT(XDA_PHYSICAL_READS) / FLOAT(XDA_LOGICAL_READS))) * 100,5,2) ELSE NULL END AS XDA_HIT_RATIO_PERCENT FROM TBSP_DATA;

CREATE VIEW "SYSIBMADM"."MON_WORKLOAD_SUMMARY" ("WORKLOAD_NAME", "WORKLOAD_ID", "TOTAL_APP_COMMITS", "TOTAL_APP_ROLLBACKS", "ACT_COMPLETED_TOTAL", "APP_RQSTS_COMPLETED_TOTAL", "AVG_RQST_CPU_TIME", "ROUTINE_TIME_RQST_PERCENT", "RQST_WAIT_TIME_PERCENT", "ACT_WAIT_TIME_PERCENT", "IO_WAIT_TIME_PERCENT", "LOCK_WAIT_TIME_PERCENT", "AGENT_WAIT_TIME_PERCENT", "NETWORK_WAIT_TIME_PERCENT", "SECTION_PROC_TIME_PERCENT", "SECTION_SORT_PROC_TIME_PERCENT", "COMPILE_PROC_TIME_PERCENT", "TRANSACT_END_PROC_TIME_PERCENT", "UTILS_PROC_TIME_PERCENT", "AVG_LOCK_WAITS_PER_ACT", "AVG_LOCK_TIMEOUTS_PER_ACT", "AVG_DEADLOCKS_PER_ACT", "AVG_LOCK_ESCALS_PER_ACT", "ROWS_READ_PER_ROWS_RETURNED", "TOTAL_BP_HIT_RATIO_PERCENT") AS
WITH METRICS AS (SELECT WORKLOAD_NAME, WORKLOAD_ID, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_COMPLETED_TOTAL + ACT_ABORTED_TOTAL) AS ACT_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(TCPIP_SEND_WAIT_TIME + TCPIP_RECV_WAIT_TIME + IPC_SEND_WAIT_TIME + IPC_RECV_WAIT_TIME) AS NETWORK_WAIT_TIME, SUM(TOTAL_RQST_TIME - TOTAL_WAIT_TIME) AS PROC_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME + TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME + TOTAL_ROLLBACK_PROC_TIME) AS TRANSACT_END_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME + TOTAL_REORG_PROC_TIME + TOTAL_LOAD_PROC_TIME) AS UTILS_PROC_TIME, SUM(POOL_DATA_L_READS + POOL_TEMP_DATA_L_READS + POOL_INDEX_L_READS + POOL_TEMP_INDEX_L_READS + POOL_XDA_L_READS + POOL_TEMP_XDA_L_READS) AS L_READS, SUM(POOL_DATA_P_READS + POOL_TEMP_DATA_P_READS + POOL_INDEX_P_READS + POOL_TEMP_INDEX_P_READS + POOL_XDA_P_READS + POOL_TEMP_XDA_P_READS) AS P_READS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME FROM TABLE(MON_GET_WORKLOAD(NULL, -2)) GROUP BY WORKLOAD_NAME, WORKLOAD_ID) SELECT WORKLOAD_NAME, WORKLOAD_ID, TOTAL_APP_COMMITS, TOTAL_APP_ROLLBACKS, ACT_COMPLETED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, CASE WHEN APP_RQSTS_COMPLETED_TOTAL > 0 THEN (TOTAL_CPU_TIME / APP_RQSTS_COMPLETED_TOTAL) ELSE NULL END AS AVG_RQST_CPU_TIME, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_ROUTINE_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS ROUTINE_TIME_RQST_PERCENT, CASE WHEN TOTAL_RQST_TIME > 0 THEN DEC(FLOAT(TOTAL_WAIT_TIME) / FLOAT(TOTAL_RQST_TIME) * 100, 5, 2) ELSE NULL END AS RQST_WAIT_TIME_PERCENT, CASE WHEN TOTAL_ACT_TIME > 0 THEN DEC(FLOAT(TOTAL_ACT_WAIT_TIME) / FLOAT(TOTAL_ACT_TIME) * 100, 5, 2) ELSE NULL END AS ACT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(IO_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS IO_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(LOCK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS LOCK_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(AGENT_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS AGENT_WAIT_TIME_PERCENT, CASE WHEN TOTAL_WAIT_TIME > 0 THEN DEC(FLOAT(NETWORK_WAIT_TIME) / FLOAT(TOTAL_WAIT_TIME) * 100, 5, 2) ELSE NULL END AS NETWORK_WAIT_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(SECTION_SORT_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS SECTION_SORT_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(COMPILE_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS COMPILE_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(TRANSACT_END_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS TRANSACT_END_PROC_TIME_PERCENT, CASE WHEN PROC_TIME > 0 THEN DEC(FLOAT(UTILS_PROC_TIME) / FLOAT(PROC_TIME) * 100, 5, 2) ELSE NULL END AS UTILS_PROC_TIME_PERCENT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_WAITS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_WAITS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_TIMEOUTS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_TIMEOUTS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN DEADLOCKS / ACT_TOTAL ELSE NULL END AS AVG_DEADLOCKS_PER_ACT, CASE WHEN ACT_TOTAL > 0 THEN LOCK_ESCALS / ACT_TOTAL ELSE NULL END AS AVG_LOCK_ESCALS_PER_ACT, CASE WHEN ROWS_RETURNED > 0 THEN ROWS_READ / ROWS_RETURNED ELSE NULL END AS ROWS_READ_PER_ROWS_RETURNED, CASE WHEN L_READS > 0 THEN DEC((1 - (FLOAT(P_READS) / FLOAT(L_READS))) * 100, 5, 2) ELSE NULL END AS TOTAL_BP_HIT_RATIO_PERCENT FROM METRICS;

CREATE VIEW "SYSIBMADM"."NOTIFICATIONLIST" ("NAME", "TYPE") AS
SELECT  NOTIFICATIONLIST.NAME, NOTIFICATIONLIST.TYPE FROM TABLE(SYSPROC.HEALTH_GET_NOTIFICATION_LIST()) AS NOTIFICATIONLIST;

CREATE VIEW "SYSIBMADM"."OBJECTOWNERS" ("OWNER", "OWNERTYPE", "OBJECTNAME", "OBJECTSCHEMA", "OBJECTTYPE") AS
 SELECT DEFINER, 'U', NAME, CREATOR,  CASE type    WHEN 'A' THEN 'ALIAS'    WHEN 'H' THEN 'HIERARCHY TABLE'    WHEN 'N' THEN 'NICKNAME'    WHEN 'S' THEN 'MATERIALIZED QUERY TABLE'    WHEN 'T' THEN 'TABLE'    WHEN 'U' THEN 'TYPED TABLE'    WHEN 'V' THEN 'VIEW'    WHEN 'W' THEN 'TYPED VIEW'  END FROM SYSIBM.SYSTABLES UNION ALL SELECT OWNER, 'U', NAME, NAME, 'SCHEMA' FROM SYSIBM.SYSSCHEMATA  UNION ALL SELECT DEFINER, 'U', SPECIFICNAME, ROUTINESCHEMA,  CASE ROUTINETYPE     WHEN 'F' THEN 'FUNCTION'     WHEN 'M' THEN 'METHOD'     WHEN 'P' THEN 'PROCEDURE'  END FROM SYSIBM.SYSROUTINES WHERE ROUTINEMODULEID IS NULL  UNION ALL SELECT DEFINER, 'U', NAME, CREATOR, 'INDEX'  FROM SYSIBM.SYSINDEXES  UNION ALL SELECT DEFINER, 'U', TBSPACE, '',    CASE TBSPACETYPE      WHEN 'S' THEN 'SYSTEM MANAGED SPACE'      WHEN 'D' THEN 'DATABASE MANAGED SPACE'   END FROM SYSIBM.SYSTABLESPACES  UNION ALL SELECT BOUNDBY, 'U', NAME, CREATOR, 'DB2 PACKAGE' FROM SYSIBM.SYSPLAN  UNION ALL SELECT DEFINER, 'U', SEQNAME, SEQSCHEMA,   CASE SEQTYPE      WHEN 'S' THEN 'SEQUENCE'      WHEN 'I' THEN 'SEQUENCE'      WHEN 'A' THEN 'ALIAS'   END FROM SYSIBM.SYSSEQUENCES  UNION ALL SELECT DEFINER, 'U', IENAME, IESCHEMA, 'INDEXEXTENSIONS' FROM SYSIBM.SYSINDEXEXTENSIONS  UNION ALL SELECT DEFINER, 'U', NAME, '', 'DBPARTITIONGROUP' FROM SYSIBM.SYSNODEGROUPS  UNION ALL SELECT DEFINER, 'U', NAME, '', 'EVENTMONITORS' FROM SYSIBM.SYSEVENTMONITORS  UNION ALL SELECT OWNER, 'U', XSROBJECTNAME, XSROBJECTSCHEMA,   CASE OBJECTTYPE     WHEN 'S' THEN 'XML SCHEMA'     WHEN 'D' THEN 'DTD'     WHEN 'E' THEN 'EXTERNAL ENTITY'   END FROM SYSIBM.SYSXSROBJECTS  UNION ALL SELECT DEFINER, 'U', TYPE_MAPPING, TYPESCHEMA, 'TYPE_MAPPINGS' FROM SYSIBM.SYSTYPEMAPPINGS  UNION ALL SELECT DEFINER, 'U', FUNCTION_MAPPING, FUNCSCHEMA, 'FUNCTION_MAPPING' FROM SYSIBM.SYSFUNCMAPPINGS  UNION ALL SELECT DEFINER, 'U', NAME, SCHEMA, 'DATATYPE' FROM SYSIBM.SYSDATATYPES WHERE TYPEMODULEID IS NULL  UNION ALL SELECT DEFINER, 'U', NAME, SCHEMA, 'TRIGGER' FROM SYSIBM.SYSTRIGGERS  UNION ALL SELECT DEFINER, 'U', NAME, TBCREATOR, 'TABLE CONSTRAINT' FROM SYSIBM.SYSTABCONST  UNION ALL SELECT OWNER, OWNERTYPE, VARNAME, VARSCHEMA, 'GLOBAL VARIABLE' FROM SYSIBM.SYSVARIABLES WHERE VARMODULEID IS NULL  UNION ALL SELECT OWNER, 'U', MODULENAME, MODULESCHEMA,  CASE MODULETYPE    WHEN 'M' THEN 'MODULE'    WHEN 'A' THEN 'ALIAS'  END FROM SYSIBM.SYSMODULES;

CREATE VIEW "SYSIBMADM"."PDLOGMSGS_LAST24HOURS" ("TIMESTAMP", "TIMEZONE", "INSTANCENAME", "DBPARTITIONNUM", "DBNAME", "PID", "PROCESSNAME", "TID", "APPL_ID", "COMPONENT", "FUNCTION", "PROBE", "MSGNUM", "MSGTYPE", "MSGSEVERITY", "MSG") AS
SELECT  MSGS.TIMESTAMP, MSGS.TIMEZONE, MSGS.INSTANCENAME, MSGS.DBPARTITIONNUM,  MSGS.DBNAME, MSGS.PID, MSGS.PROCESSNAME, MSGS.TID, MSGS.APPL_ID,  MSGS.COMPONENT, MSGS.FUNCTION, MSGS.PROBE, MSGS.MSGNUM, MSGS.MSGTYPE,  MSGS.MSGSEVERITY, MSGS.MSG FROM TABLE(SYSPROC.PD_GET_LOG_MSGS( CURRENT_TIMESTAMP - 1 DAY )) AS MSGS;

CREATE VIEW "SYSIBMADM"."PRIVILEGES" ("AUTHID", "AUTHIDTYPE", "PRIVILEGE", "GRANTABLE", "OBJECTNAME", "OBJECTSCHEMA", "OBJECTTYPE") AS
WITH TABLEVIEWNICKNAME(OWNER, OWNERTYPE, OBJECTNAME, OBJECTSCHEMA, OBJECTTYPE)  AS (   SELECT DEFINER, 'U', NAME, CREATOR,      CASE type       WHEN 'A' THEN 'ALIAS'       WHEN 'H' THEN 'HIERARCHY TABLE'       WHEN 'N' THEN 'NICKNAME'       WHEN 'S' THEN 'MATERIALIZED QUERY TABLE'       WHEN 'T' THEN 'TABLE'       WHEN 'U' THEN 'TYPED TABLE'       WHEN 'V' THEN 'VIEW'       WHEN 'W' THEN 'TYPED VIEW'     END   FROM SYSIBM.SYSTABLES ),  TABLEVIEWNICKNAMEAUTH (GRANTEE, GRANTEETYPE, TCREATOR, TTNAME, CONTROLAUTH,                        ALTERAUTH, DELETEAUTH, INDEXAUTH, INSERTAUTH, SELECTAUTH,                        REFAUTH, UPDATEAUTH, TYPE)  AS (   SELECT A.GRANTEE, A.GRANTEETYPE, A.TCREATOR, A.TTNAME, A.CONTROLAUTH, A.ALTERAUTH,          A.DELETEAUTH, A.INDEXAUTH, A.INSERTAUTH, A.SELECTAUTH, A.REFAUTH, A.UPDATEAUTH,          B.OBJECTTYPE   FROM SYSIBM.SYSTABAUTH A, TABLEVIEWNICKNAME B   WHERE A.TCREATOR = B.OBJECTSCHEMA AND A.TTNAME = B.OBJECTNAME)  SELECT GRANTEE, GRANTEETYPE, 'CONTROL',   CASE CONTROLAUTH         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE CONTROLAUTH != 'N'  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'ALTER',   CASE ALTERAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE ALTERAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'DELETE',   CASE DELETEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE DELETEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'INDEX',   CASE INDEXAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE INDEXAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'INSERT',   CASE INSERTAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE INSERTAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'SELECT',   CASE SELECTAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE SELECTAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'REFERENCE',   CASE DELETEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE REFAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'UPDATE',   CASE UPDATEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TTNAME, TCREATOR, TYPE FROM TABLEVIEWNICKNAMEAUTH WHERE UPDATEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'ALTERIN',   CASE ALTERINAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   '', SCHEMANAME, 'SCHEMA' FROM SYSIBM.SYSSCHEMAAUTH WHERE ALTERINAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'CREATEIN',   CASE CREATEINAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   '', SCHEMANAME, 'SCHEMA' FROM SYSIBM.SYSSCHEMAAUTH WHERE CREATEINAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'DROPIN',   CASE DROPINAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   '', SCHEMANAME, 'SCHEMA' FROM SYSIBM.SYSSCHEMAAUTH WHERE DROPINAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'CONTROL', 'N', NAME, CREATOR, 'INDEX' FROM SYSIBM.SYSINDEXAUTH WHERE CONTROLAUTH = 'Y'  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'USE',   CASE USEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   TBSPACE, '', 'TABLESPACE' FROM SYSIBM.SYSTBSPACEAUTH WHERE USEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'EXECUTE',   CASE EXECUTEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   SPECIFICNAME, SCHEMA,   CASE ROUTINETYPE         WHEN 'F' THEN 'FUNCTION'         WHEN 'M' THEN 'METHOD'         WHEN 'P' THEN 'PROCEDURE'   END FROM SYSIBM.SYSROUTINEAUTH WHERE EXECUTEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'CONTROL', 'N', NAME, CREATOR,        'DB2 PACKAGE' FROM SYSIBM.SYSPLANAUTH WHERE CONTROLAUTH = 'Y'  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'BIND',   CASE BINDAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   NAME, CREATOR, 'DB2 PACKAGE' FROM SYSIBM.SYSPLANAUTH WHERE BINDAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'EXECUTE',   CASE EXECUTEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   NAME, CREATOR, 'DB2 PACKAGE' FROM SYSIBM.SYSPLANAUTH WHERE EXECUTEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'USAGE',   CASE USAGEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.SEQNAME, B.SEQSCHEMA, 'SEQUENCE' FROM SYSIBM.SYSSEQUENCEAUTH AS A, SYSIBM.SYSSEQUENCES AS B WHERE A.SEQID = B.SEQID AND A.USAGEAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'ALTER',   CASE ALTERAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.SEQNAME, B.SEQSCHEMA, 'SEQUENCE' FROM SYSIBM.SYSSEQUENCEAUTH AS A, SYSIBM.SYSSEQUENCES AS B WHERE A.SEQID = B.SEQID AND A.ALTERAUTH IN ('G', 'Y')  UNION ALL SELECT GRANTEE, GRANTEETYPE, 'PASSTHROUGH', '-', SERVERNAME, '', 'DATA SOURCE' FROM SYSIBM.SYSPASSTHRUAUTH  UNION ALL SELECT A.GRANTEE, A.GRANTEETYPE, 'USAGE',   CASE A.USAGEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.XSROBJECTNAME, B.XSROBJECTSCHEMA, 'XML OBJECT' FROM SYSIBM.SYSXSROBJECTAUTH AS A, SYSIBM.SYSXSROBJECTS AS B WHERE A.XSROBJECTID = B.XSROBJECTID AND A.USAGEAUTH IN ('G', 'Y')  UNION ALL SELECT A.GRANTEE, A.GRANTEETYPE, 'READ',   CASE A.READAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.VARNAME, B.VARSCHEMA, 'GLOBAL VARIABLE' FROM SYSIBM.SYSVARIABLEAUTH AS A, SYSIBM.SYSVARIABLES AS B WHERE A.VARID = B.VARID AND A.READAUTH IN ('G', 'Y')  UNION ALL SELECT A.GRANTEE, A.GRANTEETYPE, 'WRITE',   CASE A.WRITEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.VARNAME, B.VARSCHEMA, 'GLOBAL VARIABLE' FROM SYSIBM.SYSVARIABLEAUTH AS A, SYSIBM.SYSVARIABLES AS B WHERE A.VARID = B.VARID AND A.WRITEAUTH IN ('G', 'Y')  UNION ALL SELECT A.GRANTEE, A.GRANTEETYPE, 'USAGE',   CASE A.USAGEAUTH         WHEN 'G' THEN 'Y'         WHEN 'Y' THEN 'N'   END,   B.WORKLOADNAME, '', 'WORKLOAD' FROM SYSIBM.SYSWORKLOADAUTH AS A, SYSIBM.SYSWORKLOADS AS B WHERE A.WORKLOADID = B.WORKLOADID AND A.USAGEAUTH IN ('G', 'Y')  UNION ALL SELECT A.GRANTEE, A.GRANTEETYPE, 'EXECUTE',   CASE A.EXECUTEAUTH        WHEN 'G' THEN 'Y'        ELSE 'N'   END,   B.MODULENAME, B.MODULESCHEMA, 'MODULE' FROM SYSIBM.SYSMODULEAUTH AS A, SYSIBM.SYSMODULES AS B WHERE A.MODULEID = B.MODULEID AND A.EXECUTEAUTH IN ('G', 'Y');

CREATE VIEW "SYSIBMADM"."SNAPDYN_SQL" ("SNAPSHOT_TIMESTAMP", "NUM_EXECUTIONS", "NUM_COMPILATIONS", "PREP_TIME_WORST", "PREP_TIME_BEST", "INT_ROWS_DELETED", "INT_ROWS_INSERTED", "INT_ROWS_UPDATED", "ROWS_READ", "ROWS_WRITTEN", "STMT_SORTS", "SORT_OVERFLOWS", "TOTAL_SORT_TIME", "POOL_DATA_L_READS", "POOL_DATA_P_READS", "POOL_TEMP_DATA_L_READS", "POOL_TEMP_DATA_P_READS", "POOL_INDEX_L_READS", "POOL_INDEX_P_READS", "POOL_TEMP_INDEX_L_READS", "POOL_TEMP_INDEX_P_READS", "POOL_XDA_L_READS", "POOL_XDA_P_READS", "POOL_TEMP_XDA_L_READS", "POOL_TEMP_XDA_P_READS", "TOTAL_EXEC_TIME", "TOTAL_EXEC_TIME_MS", "TOTAL_USR_CPU_TIME", "TOTAL_USR_CPU_TIME_MS", "TOTAL_SYS_CPU_TIME", "TOTAL_SYS_CPU_TIME_MS", "STMT_TEXT", "DBPARTITIONNUM", "STATS_FABRICATE_TIME", "SYNC_RUNSTATS_TIME") AS
SELECT  snapshot_timestamp, num_executions, num_compilations, prep_time_worst,  prep_time_best, int_rows_deleted, int_rows_inserted, int_rows_updated,  rows_read, rows_written, stmt_sorts, sort_overflows, total_sort_time,  pool_data_l_reads, pool_data_p_reads, pool_temp_data_l_reads,  pool_temp_data_p_reads, pool_index_l_reads, pool_index_p_reads,  pool_temp_index_l_reads, pool_temp_index_p_reads, pool_xda_l_reads,  pool_xda_p_reads, pool_temp_xda_l_reads, pool_temp_xda_p_reads,  total_exec_time, total_exec_time_ms, total_usr_cpu_time,  total_usr_cpu_time_ms, total_sys_cpu_time, total_sys_cpu_time_ms,  stmt_text, dbpartitionnum,  stats_fabricate_time, sync_runstats_time FROM TABLE(SYSPROC.SNAP_GET_DYN_SQL_V95 ('')) as t;

CREATE VIEW "SYSIBMADM"."QUERY_PREP_COST" ("SNAPSHOT_TIMESTAMP", "NUM_EXECUTIONS", "AVERAGE_EXECUTION_TIME_S", "AVERAGE_EXECUTION_TIME_MS", "PREP_TIME_MS", "PREP_TIME_PERCENT", "STMT_TEXT", "DBPARTITIONNUM") AS
SELECT  SNAPSHOT_TIMESTAMP, NUM_EXECUTIONS, TOTAL_EXEC_TIME / NUM_EXECUTIONS,  ((TOTAL_EXEC_TIME - ((TOTAL_EXEC_TIME / NUM_EXECUTIONS) * NUM_EXECUTIONS)) * 1000000 + TOTAL_EXEC_TIME_MS) / NUM_EXECUTIONS,  PREP_TIME_WORST,  CASE WHEN TOTAL_EXEC_TIME = 0 AND TOTAL_EXEC_TIME_MS = 0  THEN 100.00  ELSE DEC( ( DOUBLE(PREP_TIME_WORST * 1000) /              DOUBLE(TOTAL_EXEC_TIME * 1000000 + TOTAL_EXEC_TIME_MS)             ) * 100, 8, 2 )  END,  STMT_TEXT, DBPARTITIONNUM FROM SYSIBMADM.SNAPDYN_SQL WHERE NUM_EXECUTIONS > 0;

CREATE VIEW "SYSIBMADM"."REG_VARIABLES" ("DBPARTITIONNUM", "REG_VAR_NAME", "REG_VAR_VALUE", "IS_AGGREGATE", "AGGREGATE_NAME", "LEVEL") AS
SELECT  dbpartitionnum, reg_var_name, reg_var_value, is_aggregate,  aggregate_name, level FROM TABLE(SYSPROC.REG_LIST_VARIABLES()) as t;

CREATE VIEW "SYSIBMADM"."ROLE_ROLE_PRIVS" ("GRANTEE", "GRANTED_ROLE", "ADMIN_OPTION") AS
SELECT   GRANTEE  ,ROLENAME  ,CAST( CASE ADMIN   WHEN 'Y' THEN 'YES'   WHEN 'N' THEN 'NO'   END AS VARCHAR(3) ) FROM SYSCAT.ROLEAUTH WHERE GRANTEETYPE = 'R';

CREATE VIEW "SYSIBMADM"."ROLE_SYS_PRIVS" ("ROLE", "PRIVILEGE", "ADMIN_OPTION") AS
SELECT GRANTEE, CAST( 'BINDADD' AS VARCHAR(25) ), CAST( CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END AS VARCHAR(3) ) FROM SYSCAT.DBAUTH WHERE BINDADDAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CONNECTAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'CREATETAB', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CREATETABAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'DBADM', 'NO' FROM SYSCAT.DBAUTH WHERE DBADMAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'CREATE_EXTERNAL_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXTERNALROUTINEAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'IMPLICIT_SCHEMA', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE IMPLSCHEMAAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'LOAD', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LOADAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'CREATE_NOT_FENCED_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE NOFENCEAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'QUIESCE_CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE QUIESCECONNECTAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'LIBADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LIBRARYADMAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'SECADM', 'NO' FROM SYSCAT.DBAUTH WHERE SECURITYADMAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'SQLADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE SQLADMAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'WLMADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE WLMADMAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'EXPLAIN', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXPLAINAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'DATAACCESS', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE DATAACCESSAUTH = 'Y' AND GRANTEETYPE = 'R' UNION ALL SELECT GRANTEE, 'ACCESSCTRL', CASE  DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE ACCESSCTRLAUTH = 'Y' AND GRANTEETYPE = 'R';

CREATE VIEW "SYSIBMADM"."ROLE_TAB_PRIVS" ("ROLE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "PRIVILEGE", "GRANTABLE") AS
WITH TABVIEW_PRIVS(GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, CONTROLAUTH, ALTERAUTH,                    DELETEAUTH, INDEXAUTH, INSERTAUTH, SELECTAUTH, REFAUTH, UPDATEAUTH)        AS ( SELECT A.GRANTEE, B.OWNER, A.TABSCHEMA, A.TABNAME, A.GRANTOR, A.CONTROLAUTH, A.ALTERAUTH,                     A.DELETEAUTH, A.INDEXAUTH, A.INSERTAUTH, A.SELECTAUTH, A.REFAUTH, A.UPDATEAUTH             FROM SYSCAT.TABAUTH A, SYSCAT.TABLES B             WHERE A.TABSCHEMA = B.TABSCHEMA AND A.TABNAME = B.TABNAME AND A.GRANTEETYPE = 'R'),        SEQ_PRIVS(GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, ALTERAUTH, USAGEAUTH)        AS ( SELECT SEQAUTH.GRANTEE, SEQ.OWNER, SEQAUTH.SEQSCHEMA, SEQAUTH.SEQNAME,                    SEQAUTH.GRANTOR, SEQAUTH.ALTERAUTH, SEQAUTH.USAGEAUTH             FROM SYSCAT.SEQUENCEAUTH SEQAUTH, SYSCAT.SEQUENCES SEQ             WHERE SEQAUTH.SEQSCHEMA = SEQ.SEQSCHEMA AND SEQAUTH.SEQNAME = SEQ.SEQNAME               AND SEQAUTH.GRANTEETYPE = 'R'),     PKG_PRIVS(GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, CONTROLAUTH, BINDAUTH, EXECUTEAUTH)        AS ( SELECT PKGAUTH.GRANTEE, PKG.OWNER, PKGAUTH.PKGSCHEMA, PKGAUTH.PKGNAME, PKGAUTH.GRANTOR,                     PKGAUTH.CONTROLAUTH, PKGAUTH.BINDAUTH, PKGAUTH.EXECUTEAUTH             FROM SYSCAT.PACKAGEAUTH PKGAUTH, SYSCAT.PACKAGES PKG             WHERE PKGAUTH.PKGSCHEMA = PKG.PKGSCHEMA AND PKGAUTH.PKGNAME = PKG.PKGNAME               AND PKGAUTH.GRANTEETYPE = 'R'),     FUNCPROC_PRIVS(GRANTEE, OWNER, ROUTSCHEMA, ROUTNAME, GRANTOR, EXECUTEAUTH)        AS ( SELECT AUTH.GRANTEE, RTS.OWNER, RTS.ROUTINESCHEMA, RTS.ROUTINENAME, AUTH.GRANTOR, AUTH.EXECUTEAUTH             FROM SYSCAT.ROUTINEAUTH AUTH, SYSCAT.ROUTINES RTS             WHERE AUTH.SPECIFICNAME IS NOT NULL AND AUTH.SCHEMA = RTS.ROUTINESCHEMA AND                   AUTH.SPECIFICNAME = RTS.SPECIFICNAME AND AUTH.GRANTEETYPE = 'R') SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, CAST( 'CONTROL' AS VARCHAR(9) ), CAST( 'NO' AS VARCHAR(3) ) FROM TABVIEW_PRIVS WHERE CONTROLAUTH = 'Y' UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'ALTER', CASE ALTERAUTH WHEN 'G' THEN 'YES' ELSE 'N' END   FROM TABVIEW_PRIVS WHERE ALTERAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'DELETE', CASE DELETEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE DELETEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'INDEX', CASE INDEXAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE INDEXAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'INSERT', CASE INSERTAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE INSERTAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'REFERENCE', CASE REFAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE REFAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'SELECT', CASE SELECTAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE SELECTAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, TABSCHEMA, TABNAME, GRANTOR, 'UPDATE', CASE UPDATEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM TABVIEW_PRIVS WHERE UPDATEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, 'ALTER', CASE ALTERAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM SEQ_PRIVS WHERE ALTERAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, SEQSCHEMA, SEQNAME, GRANTOR, 'USAGE', CASE USAGEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM SEQ_PRIVS WHERE USAGEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'CONTROL', 'NO' FROM        PKG_PRIVS WHERE CONTROLAUTH = 'Y' UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'BIND', CASE BINDAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM PKG_PRIVS WHERE BINDAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, PKGSCHEMA, PKGNAME, GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM PKG_PRIVS WHERE EXECUTEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, OWNER, ROUTSCHEMA, ROUTNAME, GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END   FROM FUNCPROC_PRIVS WHERE EXECUTEAUTH IN ('Y','G') UNION ALL SELECT GRANTEE, '', SCHEMA, CASE ROUTINETYPE WHEN 'P' THEN 'ALL PROCEDURES' WHEN 'F' THEN 'ALL FUNCTIONS' END,   GRANTOR, 'EXECUTE', CASE EXECUTEAUTH WHEN 'G' THEN 'YES' ELSE 'NO' END FROM SYSCAT.ROUTINEAUTH   WHERE SPECIFICNAME IS NULL AND ROUTINETYPE IN ('P','F') AND GRANTEETYPE = 'R';

CREATE VIEW "SYSIBMADM"."USER_SYS_PRIVS" ("USERNAME", "PRIVILEGE", "ADMIN_OPTION") AS
SELECT GRANTEE, CAST( 'BINDADD' AS VARCHAR(25) ), CAST( CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END AS VARCHAR(3) ) FROM SYSCAT.DBAUTH WHERE BINDADDAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CONNECTAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'CREATETAB', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE CREATETABAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'DBADM', 'NO' FROM SYSCAT.DBAUTH WHERE DBADMAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'CREATE_EXTERNAL_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXTERNALROUTINEAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'IMPLICIT_SCHEMA', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE IMPLSCHEMAAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'LOAD', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LOADAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'CREATE_NOT_FENCED_ROUTINE', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE NOFENCEAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'QUIESCE_CONNECT', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE QUIESCECONNECTAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'LIBADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE LIBRARYADMAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'SECADM', 'NO' FROM SYSCAT.DBAUTH WHERE SECURITYADMAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'SQLADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE SQLADMAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'WLMADM', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE WLMADMAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'EXPLAIN', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE EXPLAINAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'DATAACCESS', CASE DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE DATAACCESSAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U' UNION ALL SELECT GRANTEE, 'ACCESSCTRL', CASE  DBADMAUTH WHEN 'Y' THEN 'YES' ELSE 'NO' END FROM SYSCAT.DBAUTH WHERE ACCESSCTRLAUTH = 'Y' AND GRANTEE = CURRENT USER AND GRANTEETYPE = 'U';

CREATE VIEW "SYSIBMADM"."USER_ROLE_PRIVS" ("USERNAME", "GRANTED_ROLE", "ADMIN_OPTION", "DEFAULT_ROLE", "OS_GRANTED") AS
SELECT   GRANTEE  ,ROLENAME  ,CAST( CASE ADMIN   WHEN 'Y' THEN 'YES'   WHEN 'N' THEN 'NO'   END AS VARCHAR(3) )  ,CAST( 'YES' AS VARCHAR(3) )  ,CAST( 'NO' AS VARCHAR(2) ) FROM SYSCAT.ROLEAUTH WHERE (GRANTEE = CURRENT USER AND GRANTEETYPE = 'U') OR GRANTEE = 'PUBLIC';

CREATE VIEW "SYSIBMADM"."SESSION_PRIVS" ("PRIVILEGE") AS
WITH ALL_PRIVS AS ( SELECT PRIVILEGE FROM SYSIBMADM.USER_SYS_PRIVS UNION ALL SELECT SYS.PRIVILEGE FROM SYSIBMADM.ROLE_SYS_PRIVS SYS, SYSIBMADM.USER_ROLE_PRIVS ROLE   WHERE SYS.ROLE = ROLE.GRANTED_ROLE AND ROLE.USERNAME = CURRENT USER) SELECT DISTINCT(PRIVILEGE) FROM ALL_PRIVS;

CREATE VIEW "SYSIBMADM"."SESSION_ROLES" ("ROLE") AS
SELECT   GRANTED_ROLE AS ROLE FROM SYSIBMADM.USER_ROLE_PRIVS;

CREATE VIEW "SYSIBMADM"."SNAPAGENT" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "AGENT_PID", "LOCK_TIMEOUT_VAL", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, agent_id, agent_pid, lock_timeout_val, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_AGENT(' ')) as T;

CREATE VIEW "SYSIBMADM"."SNAPAGENT_MEMORY_POOL" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "AGENT_ID", "AGENT_PID", "POOL_ID", "POOL_CUR_SIZE", "POOL_WATERMARK", "POOL_CONFIG_SIZE", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, agent_id, agent_pid, pool_id,  pool_cur_size, pool_watermark, pool_config_size, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_AGENT_MEMORY_POOL(' ')) as T;

CREATE VIEW "SYSIBMADM"."SNAPBP_PART" ("SNAPSHOT_TIMESTAMP", "BP_NAME", "DB_NAME", "BP_CUR_BUFFSZ", "BP_NEW_BUFFSZ", "BP_PAGES_LEFT_TO_REMOVE", "BP_TBSP_USE_COUNT", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, bp_name, db_name, bp_cur_buffsz, bp_new_buffsz,  bp_pages_left_to_remove, bp_tbsp_use_count, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_BP_PART(' ')) as T;

CREATE VIEW "SYSIBMADM"."SNAPDBM" ("SNAPSHOT_TIMESTAMP", "SORT_HEAP_ALLOCATED", "POST_THRESHOLD_SORTS", "PIPED_SORTS_REQUESTED", "PIPED_SORTS_ACCEPTED", "REM_CONS_IN", "REM_CONS_IN_EXEC", "LOCAL_CONS", "LOCAL_CONS_IN_EXEC", "CON_LOCAL_DBASES", "AGENTS_REGISTERED", "AGENTS_WAITING_ON_TOKEN", "DB2_STATUS", "AGENTS_REGISTERED_TOP", "AGENTS_WAITING_TOP", "COMM_PRIVATE_MEM", "IDLE_AGENTS", "AGENTS_FROM_POOL", "AGENTS_CREATED_EMPTY_POOL", "COORD_AGENTS_TOP", "MAX_AGENT_OVERFLOWS", "AGENTS_STOLEN", "GW_TOTAL_CONS", "GW_CUR_CONS", "GW_CONS_WAIT_HOST", "GW_CONS_WAIT_CLIENT", "POST_THRESHOLD_HASH_JOINS", "NUM_GW_CONN_SWITCHES", "DB2START_TIME", "LAST_RESET", "NUM_NODES_IN_DB2_INSTANCE", "PRODUCT_NAME", "SERVICE_LEVEL", "SORT_HEAP_TOP", "DBPARTITIONNUM", "POST_THRESHOLD_OLAP_FUNCS") AS
SELECT  snapshot_timestamp, sort_heap_allocated, post_threshold_sorts, piped_sorts_requested,  piped_sorts_accepted, rem_cons_in, rem_cons_in_exec, local_cons, local_cons_in_exec,  con_local_dbases, agents_registered, agents_waiting_on_token, db2_status,  agents_registered_top, agents_waiting_top, comm_private_mem, idle_agents,  agents_from_pool, agents_created_empty_pool, coord_agents_top, max_agent_overflows,  agents_stolen, gw_total_cons, gw_cur_cons, gw_cons_wait_host, gw_cons_wait_client,  post_threshold_hash_joins, num_gw_conn_switches, db2start_time, last_reset,  num_nodes_in_db2_instance, product_name, service_level, sort_heap_top, dbpartitionnum,  post_threshold_olap_funcs FROM TABLE(SYSPROC.SNAP_GET_DBM_V95()) as T;

CREATE VIEW "SYSIBMADM"."SNAPDBM_MEMORY_POOL" ("SNAPSHOT_TIMESTAMP", "POOL_ID", "POOL_CUR_SIZE", "POOL_WATERMARK", "POOL_CONFIG_SIZE", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, pool_id, pool_cur_size,  pool_watermark, pool_config_size, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_DBM_MEMORY_POOL()) as T;

CREATE VIEW "SYSIBMADM"."SNAPDB_MEMORY_POOL" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "POOL_ID", "POOL_SECONDARY_ID", "POOL_CUR_SIZE", "POOL_WATERMARK", "POOL_CONFIG_SIZE", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, pool_id, pool_secondary_id,  pool_cur_size, pool_watermark, pool_config_size, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_DB_MEMORY_POOL(' ')) as T;

CREATE VIEW "SYSIBMADM"."SNAPDETAILLOG" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "FIRST_ACTIVE_LOG", "LAST_ACTIVE_LOG", "CURRENT_ACTIVE_LOG", "CURRENT_ARCHIVE_LOG", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, first_active_log, last_active_log,  current_active_log, current_archive_log, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_DETAILLOG_V91 (' ')) as t;

CREATE VIEW "SYSIBMADM"."SNAPFCM" ("SNAPSHOT_TIMESTAMP", "BUFF_FREE", "BUFF_FREE_BOTTOM", "CH_FREE", "CH_FREE_BOTTOM", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, buff_free, buff_free_bottom, ch_free,  ch_free_bottom, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_FCM()) as T;

CREATE VIEW "SYSIBMADM"."SNAPFCM_PART" ("SNAPSHOT_TIMESTAMP", "CONNECTION_STATUS", "TOTAL_BUFFERS_SENT", "TOTAL_BUFFERS_RCVD", "DBPARTITIONNUM", "FCM_DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, connection_status, total_buffers_sent,  total_buffers_rcvd, dbpartitionnum, fcm_dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_FCM_PART()) as T;

CREATE VIEW "SYSIBMADM"."SNAPHADR" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "HADR_ROLE", "HADR_STATE", "HADR_SYNCMODE", "HADR_CONNECT_STATUS", "HADR_CONNECT_TIME", "HADR_HEARTBEAT", "HADR_LOCAL_HOST", "HADR_LOCAL_SERVICE", "HADR_REMOTE_HOST", "HADR_REMOTE_SERVICE", "HADR_REMOTE_INSTANCE", "HADR_TIMEOUT", "HADR_PRIMARY_LOG_FILE", "HADR_PRIMARY_LOG_PAGE", "HADR_PRIMARY_LOG_LSN", "HADR_STANDBY_LOG_FILE", "HADR_STANDBY_LOG_PAGE", "HADR_STANDBY_LOG_LSN", "HADR_LOG_GAP", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, hadr_role, hadr_state, hadr_syncmode,  hadr_connect_status, hadr_connect_time, hadr_heartbeat, hadr_local_host,  hadr_local_service, hadr_remote_host, hadr_remote_service,  hadr_remote_instance, hadr_timeout, hadr_primary_log_file,  hadr_primary_log_page, hadr_primary_log_lsn, hadr_standby_log_file,  hadr_standby_log_page, hadr_standby_log_lsn, hadr_log_gap, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_HADR (' ')) as t;

CREATE VIEW "SYSIBMADM"."SNAPSTORAGE_PATHS" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "DB_STORAGE_PATH", "DB_STORAGE_PATH_WITH_DPE", "DBPARTITIONNUM", "DB_STORAGE_PATH_STATE", "FS_ID", "FS_TOTAL_SIZE", "FS_USED_SIZE", "STO_PATH_FREE_SIZE") AS
SELECT  snapshot_timestamp, db_name, db_storage_path, db_storage_path_with_dpe, dbpartitionnum, db_storage_path_state, fs_id, fs_total_size, fs_used_size, sto_path_free_size FROM TABLE(SYSPROC.SNAP_GET_STORAGE_PATHS_V97 (' ')) as t;

CREATE VIEW "SYSIBMADM"."SNAPSUBSECTION" ("SNAPSHOT_TIMESTAMP", "DB_NAME", "STMT_TEXT", "SS_EXEC_TIME", "TQ_TOT_SEND_SPILLS", "TQ_CUR_SEND_SPILLS", "TQ_MAX_SEND_SPILLS", "TQ_ROWS_READ", "TQ_ROWS_WRITTEN", "ROWS_READ", "ROWS_WRITTEN", "SS_USR_CPU_TIME_S", "SS_USR_CPU_TIME_MS", "SS_SYS_CPU_TIME_S", "SS_SYS_CPU_TIME_MS", "SS_NUMBER", "SS_STATUS", "SS_NODE_NUMBER", "TQ_NODE_WAITED_FOR", "TQ_WAIT_FOR_ANY", "TQ_ID_WAITING_ON", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, db_name, stmt_text, ss_exec_time, tq_tot_send_spills,  tq_cur_send_spills, tq_max_send_spills, tq_rows_read, tq_rows_written,  rows_read, rows_written, ss_usr_cpu_time_s, ss_usr_cpu_time_ms, ss_sys_cpu_time_s,  ss_sys_cpu_time_ms, ss_number, ss_status, ss_node_number, tq_node_waited_for,  tq_wait_for_any, tq_id_waiting_on, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_SUBSECTION (' ')) as t;

CREATE VIEW "SYSIBMADM"."SNAPSWITCHES" ("SNAPSHOT_TIMESTAMP", "UOW_SW_STATE", "UOW_SW_TIME", "STATEMENT_SW_STATE", "STATEMENT_SW_TIME", "TABLE_SW_STATE", "TABLE_SW_TIME", "BUFFPOOL_SW_STATE", "BUFFPOOL_SW_TIME", "LOCK_SW_STATE", "LOCK_SW_TIME", "SORT_SW_STATE", "SORT_SW_TIME", "TIMESTAMP_SW_STATE", "TIMESTAMP_SW_TIME", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, uow_sw_state, uow_sw_time, statement_sw_state,  statement_sw_time, table_sw_state, table_sw_time, buffpool_sw_state,  buffpool_sw_time, lock_sw_state, lock_sw_time, sort_sw_state, sort_sw_time,  timestamp_sw_state, timestamp_sw_time, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_SWITCHES()) as t;

CREATE VIEW "SYSIBMADM"."SNAPTAB" ("SNAPSHOT_TIMESTAMP", "TABSCHEMA", "TABNAME", "TAB_FILE_ID", "TAB_TYPE", "DATA_OBJECT_PAGES", "INDEX_OBJECT_PAGES", "LOB_OBJECT_PAGES", "LONG_OBJECT_PAGES", "XDA_OBJECT_PAGES", "ROWS_READ", "ROWS_WRITTEN", "OVERFLOW_ACCESSES", "PAGE_REORGS", "DBPARTITIONNUM", "TBSP_ID", "DATA_PARTITION_ID") AS
SELECT  snapshot_timestamp, tabschema, tabname, tab_file_id, tab_type,  data_object_pages, index_object_pages, lob_object_pages, long_object_pages,  xda_object_pages, rows_read, rows_written, overflow_accesses, page_reorgs,  dbpartitionnum, tbsp_id, data_partition_id FROM TABLE(SYSPROC.SNAP_GET_TAB_V91('')) as t;

CREATE VIEW "SYSIBMADM"."SNAPTAB_REORG" ("SNAPSHOT_TIMESTAMP", "TABNAME", "TABSCHEMA", "PAGE_REORGS", "REORG_PHASE", "REORG_MAX_PHASE", "REORG_CURRENT_COUNTER", "REORG_MAX_COUNTER", "REORG_TYPE", "REORG_STATUS", "REORG_COMPLETION", "REORG_START", "REORG_END", "REORG_PHASE_START", "REORG_INDEX_ID", "REORG_TBSPC_ID", "DBPARTITIONNUM", "DATA_PARTITION_ID", "REORG_ROWSCOMPRESSED", "REORG_ROWSREJECTED", "REORG_LONG_TBSPC_ID") AS
SELECT  snapshot_timestamp, tabname, tabschema, page_reorgs, reorg_phase,  reorg_max_phase, reorg_current_counter, reorg_max_counter, reorg_type, reorg_status,  reorg_completion, reorg_start, reorg_end, reorg_phase_start, reorg_index_id,  reorg_tbspc_id, dbpartitionnum, data_partition_id, reorg_rowscompressed,  reorg_rowsrejected, reorg_long_tbspc_id FROM TABLE(SYSPROC.SNAP_GET_TAB_REORG('')) as t;

CREATE VIEW "SYSIBMADM"."SNAPTBSP_QUIESCER" ("SNAPSHOT_TIMESTAMP", "TBSP_NAME", "QUIESCER_TS_ID", "QUIESCER_OBJ_ID", "QUIESCER_AUTH_ID", "QUIESCER_AGENT_ID", "QUIESCER_STATE", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, tbsp_name, quiescer_ts_id, quiescer_obj_id,  quiescer_auth_id, quiescer_agent_id, quiescer_state, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_TBSP_QUIESCER('')) as t;

CREATE VIEW "SYSIBMADM"."SNAPTBSP_RANGE" ("SNAPSHOT_TIMESTAMP", "TBSP_ID", "TBSP_NAME", "RANGE_NUMBER", "RANGE_STRIPE_SET_NUMBER", "RANGE_OFFSET", "RANGE_MAX_PAGE", "RANGE_MAX_EXTENT", "RANGE_START_STRIPE", "RANGE_END_STRIPE", "RANGE_ADJUSTMENT", "RANGE_NUM_CONTAINER", "RANGE_CONTAINER_ID", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, tbsp_id, tbsp_name, range_number, range_stripe_set_number,  range_offset, range_max_page, range_max_extent, range_start_stripe,  range_end_stripe, range_adjustment, range_num_container, range_container_id,  dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_TBSP_RANGE('')) as t;

CREATE VIEW "SYSIBMADM"."SNAPUTIL" ("SNAPSHOT_TIMESTAMP", "UTILITY_ID", "UTILITY_TYPE", "UTILITY_PRIORITY", "UTILITY_DESCRIPTION", "UTILITY_DBNAME", "UTILITY_START_TIME", "UTILITY_STATE", "UTILITY_INVOKER_TYPE", "DBPARTITIONNUM", "PROGRESS_LIST_ATTR", "PROGRESS_LIST_CUR_SEQ_NUM") AS
SELECT  snapshot_timestamp, utility_id, utility_type, utility_priority,  utility_description, utility_dbname, utility_start_time,  utility_state, utility_invoker_type, dbpartitionnum,  progress_list_attr, progress_list_cur_seq_num FROM TABLE(SYSPROC.SNAP_GET_UTIL()) as t;

CREATE VIEW "SYSIBMADM"."SNAPUTIL_PROGRESS" ("SNAPSHOT_TIMESTAMP", "UTILITY_ID", "PROGRESS_SEQ_NUM", "UTILITY_STATE", "PROGRESS_DESCRIPTION", "PROGRESS_START_TIME", "PROGRESS_WORK_METRIC", "PROGRESS_TOTAL_UNITS", "PROGRESS_COMPLETED_UNITS", "DBPARTITIONNUM") AS
SELECT  snapshot_timestamp, utility_id, progress_seq_num, utility_state,  progress_description, progress_start_time, progress_work_metric,  progress_total_units, progress_completed_units, dbpartitionnum FROM TABLE(SYSPROC.SNAP_GET_UTIL_PROGRESS()) as t;

CREATE VIEW "SYSIBMADM"."TAB" ("TSCHEMA", "TNAME", "TABTYPE") AS
SELECT   TABSCHEMA  ,TABNAME  ,CAST( CASE TYPE   WHEN 'A' THEN 'SYNONYM'   WHEN 'G' THEN 'GLOBAL TEMPORARY TABLE'   WHEN 'H' THEN 'HIERARCHY TABLE'   WHEN 'L' THEN 'DETACHED TABLE'   WHEN 'N' THEN 'NICKNAME'   WHEN 'S' THEN 'MATERIZED QUERY TABLE'   WHEN 'T' THEN 'TABLE'   WHEN 'U' THEN 'TYPED TABLE'   WHEN 'V' THEN 'VIEW'   WHEN 'W' THEN 'TYPED VIEW'   ELSE 'UNKNOWN'   END AS VARCHAR(22) ) FROM SYSCAT.TABLES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."TBSP_UTILIZATION" ("SNAPSHOT_TIMESTAMP", "TBSP_ID", "TBSP_NAME", "TBSP_TYPE", "TBSP_CONTENT_TYPE", "TBSP_CREATE_TIME", "TBSP_STATE", "TBSP_TOTAL_SIZE_KB", "TBSP_USABLE_SIZE_KB", "TBSP_USED_SIZE_KB", "TBSP_FREE_SIZE_KB", "TBSP_UTILIZATION_PERCENT", "TBSP_TOTAL_PAGES", "TBSP_USABLE_PAGES", "TBSP_USED_PAGES", "TBSP_FREE_PAGES", "TBSP_PAGE_TOP", "TBSP_PAGE_SIZE", "TBSP_EXTENT_SIZE", "TBSP_PREFETCH_SIZE", "TBSP_MAX_SIZE", "TBSP_INCREASE_SIZE", "TBSP_INCREASE_SIZE_PERCENT", "TBSP_LAST_RESIZE_TIME", "TBSP_LAST_RESIZE_FAILED", "TBSP_USING_AUTO_STORAGE", "TBSP_AUTO_RESIZE_ENABLED", "DBPGNAME", "TBSP_NUM_CONTAINERS", "REMARKS", "DBPARTITIONNUM") AS
SELECT  S.SNAPSHOT_TIMESTAMP, S.TBSP_ID, S.TBSP_NAME, P.TBSP_TYPE, P.TBSP_CONTENT_TYPE, T.CREATE_TIME, S.TBSP_STATE, (S.TBSP_TOTAL_PAGES*T.PAGESIZE)/1024, (S.TBSP_USABLE_PAGES*T.PAGESIZE)/1024, (S.TBSP_USED_PAGES*T.PAGESIZE)/1024, (S.TBSP_FREE_PAGES*T.PAGESIZE)/1024, CASE WHEN S.TBSP_USABLE_PAGES > 0  THEN DEC(100* (FLOAT(S.TBSP_USED_PAGES)/FLOAT(S.TBSP_USABLE_PAGES)),5,2)  ELSE DEC(-1,5,2) END, S.TBSP_TOTAL_PAGES, S.TBSP_USABLE_PAGES, S.TBSP_USED_PAGES, S.TBSP_FREE_PAGES, S.TBSP_PAGE_TOP, T.PAGESIZE, T.EXTENTSIZE, CASE WHEN P.TBSP_PREFETCH_SIZE < 0   THEN S.TBSP_PREFETCH_SIZE   ELSE P.TBSP_PREFETCH_SIZE END, S.TBSP_MAX_SIZE, S.TBSP_INCREASE_SIZE, S.TBSP_INCREASE_SIZE_PERCENT, S.TBSP_LAST_RESIZE_TIME, S.TBSP_LAST_RESIZE_FAILED, P.TBSP_USING_AUTO_STORAGE, P.TBSP_AUTO_RESIZE_ENABLED, T.DBPGNAME, S.TBSP_NUM_CONTAINERS, T.REMARKS, S.DBPARTITIONNUM FROM SYSIBMADM.SNAPTBSP_PART AS S, SYSIBMADM.SNAPTBSP AS P, SYSCAT.TABLESPACES T WHERE S.TBSP_ID = T.TBSPACEID and S.TBSP_ID = P.TBSP_ID AND S.DBPARTITIONNUM = P.DBPARTITIONNUM;

CREATE VIEW "SYSIBMADM"."TOP_DYNAMIC_SQL" ("SNAPSHOT_TIMESTAMP", "NUM_EXECUTIONS", "AVERAGE_EXECUTION_TIME_S", "STMT_SORTS", "SORTS_PER_EXECUTION", "STMT_TEXT", "DBPARTITIONNUM") AS
SELECT  SNAPSHOT_TIMESTAMP, NUM_EXECUTIONS, TOTAL_EXEC_TIME / NUM_EXECUTIONS,  STMT_SORTS, STMT_SORTS / NUM_EXECUTIONS, STMT_TEXT, DBPARTITIONNUM FROM SYSIBMADM.SNAPDYN_SQL WHERE NUM_EXECUTIONS > 0;

CREATE VIEW "SYSIBMADM"."USER_TABLES" ("TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,TABLESPACE_NAME  ,PCT_FREE  ,INITIAL_EXTENT  ,NEXT_EXTENT  ,PCT_INCREASE  ,LOGGING  ,NUM_ROWS  ,BLOCKS  ,EMPTY_BLOCKS  ,AVG_ROW_LEN  ,TABLE_LOCK  ,LAST_ANALYZED  ,PARTITIONED  ,TEMPORARY  ,BUFFER_POOL  ,GLOBAL_STATS  ,COMPRESSION FROM SYSIBMADM.DBA_TABLES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_ALL_TABLES" ("TABLE_SCHEMA", "TABLE_NAME", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "NUM_ROWS", "BLOCKS", "EMPTY_BLOCKS", "AVG_ROW_LEN", "TABLE_LOCK", "LAST_ANALYZED", "PARTITIONED", "TEMPORARY", "BUFFER_POOL", "GLOBAL_STATS", "COMPRESSION") AS
SELECT * FROM SYSIBMADM.USER_TABLES;

CREATE VIEW "SYSIBMADM"."USER_ARGUMENTS" ("OWNER", "OBJECT_SCHEMA", "OBJECT_NAME", "PACKAGE_NAME", "OBJECT_ID", "ARGUMENT_NAME", "SEQUENCE", "DATA_TYPE", "IN_OUT", "DATA_LENGTH", "DATA_SCALE") AS
SELECT AG.* FROM SYSIBMADM.ALL_ARGUMENTS AG WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_CATALOG" ("TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,TABLE_TYPE  FROM SYSIBMADM.DBA_CATALOG WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_COL_COMMENTS" ("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COMMENTS") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,COLUMN_NAME  ,COMMENTS FROM SYSIBMADM.DBA_COL_COMMENTS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_CONSTRAINTS" ("OWNER", "CONSTRAINT_NAME", "CONSTRAINT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "R_OWNER", "R_CONSTRAINT_NAME", "DELETE_RULE", "DEFERRED", "STATUS", "VALIDATED", "GENERATED", "RELY", "INDEX_OWNER", "INDEX_NAME") AS
SELECT   CONS.OWNER  ,CONS.CONSTRAINT_NAME  ,CONS.CONSTRAINT_TYPE  ,CONS.TABLE_SCHEMA  ,CONS.TABLE_NAME  ,CONS.R_OWNER  ,CONS.R_CONSTRAINT_NAME  ,CONS.DELETE_RULE  ,CONS.DEFERRED  ,CONS.STATUS  ,CONS.VALIDATED  ,CONS.GENERATED  ,CONS.RELY  ,CONS.INDEX_OWNER  ,CONS.INDEX_NAME FROM SYSIBMADM.DBA_CONSTRAINTS CONS, SYSCAT.TABLES TAB WHERE CONS.TABLE_SCHEMA = TAB.TABSCHEMA AND CONS.TABLE_NAME = TAB.TABNAME      AND TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_CONS_COLUMNS" ("OWNER", "CONSTRAINT_NAME", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "POSITION") AS
SELECT CONS.* FROM SYSIBMADM.DBA_CONS_COLUMNS CONS, SYSCAT.TABLES TAB WHERE CONS.TABLE_SCHEMA = TAB.TABSCHEMA AND CONS.TABLE_NAME = TAB.TABNAME  AND TAB.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_DEPENDENCIES" ("SCHEMA", "NAME", "TYPE", "REFERENCED_SCHEMA", "REFERENCED_NAME", "REFERENCED_TYPE") AS
SELECT   SCHEMA  ,NAME  ,TYPE  ,REFERENCED_SCHEMA  ,REFERENCED_NAME  ,REFERENCED_TYPE FROM SYSIBMADM.DBA_DEPENDENCIES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_ERRORS" ("SCHEMA", "NAME", "TYPE", "LINE", "TEXT") AS
SELECT   SCHEMA  ,NAME  ,TYPE  ,LINE  ,TEXT FROM SYSIBMADM.DBA_ERRORS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_INDEXES" ("INDEX_SCHEMA", "INDEX_NAME", "INDEX_TYPE", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "UNIQUENESS", "COMPRESSION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "STATUS", "NUM_ROWS", "LAST_ANALYZED", "PARTITIONED", "GENERATED", "BUFFER_POOL") AS
SELECT   INDEX_SCHEMA  ,INDEX_NAME  ,INDEX_TYPE  ,TABLE_OWNER  ,TABLE_SCHEMA  ,TABLE_NAME  ,TABLE_TYPE  ,UNIQUENESS  ,COMPRESSION  ,TABLESPACE_NAME  ,PCT_FREE  ,LOGGING  ,BLEVEL  ,LEAF_BLOCKS  ,DISTINCT_KEYS  ,AVG_LEAF_BLOCKS_PER_KEY  ,CLUSTERING_FACTOR  ,STATUS  ,NUM_ROWS  ,LAST_ANALYZED  ,PARTITIONED  ,GENERATED  ,BUFFER_POOL FROM SYSIBMADM.DBA_INDEXES WHERE TABLE_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_IND_COLUMNS" ("INDEX_SCHEMA", "INDEX_NAME", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "COLUMN_POSITION", "DESCEND") AS
SELECT   INDEX_SCHEMA  ,INDEX_NAME  ,TABLE_SCHEMA  ,TABLE_NAME  ,COLUMN_NAME  ,COLUMN_POSITION  ,DESCEND FROM SYSIBMADM.DBA_IND_COLUMNS WHERE INDEX_OWNER = CURRENT USER OR TABLE_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_IND_PARTITIONS" ("INDEX_SCHEMA", "INDEX_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "LOGGING", "COMPRESSION", "BLEVEL", "LEAF_BLOCKS", "DISTINCT_KEYS", "AVG_LEAF_BLOCKS_PER_KEY", "CLUSTERING_FACTOR", "NUM_ROWS", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
SELECT   INDEX_SCHEMA  ,INDEX_NAME  ,PARTITION_NAME  ,HIGH_VALUE  ,HIGH_VALUE_LENGTH  ,PARTITION_POSITION  ,TABLESPACE_NAME  ,PCT_FREE  ,LOGGING  ,COMPRESSION  ,BLEVEL  ,LEAF_BLOCKS  ,DISTINCT_KEYS  ,AVG_LEAF_BLOCKS_PER_KEY  ,CLUSTERING_FACTOR  ,NUM_ROWS  ,LAST_ANALYZED  ,BUFFER_POOL  ,GLOBAL_STATS FROM SYSIBMADM.DBA_IND_PARTITIONS WHERE INDEX_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_OBJECTS" ("OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_ID", "DATA_OBJECT_ID", "OBJECT_TYPE", "CREATED", "LAST_DDL_TIME", "TIMESTAMP", "STATUS", "TEMPORARY", "GENERATED") AS
SELECT   OBJECT_SCHEMA  ,OBJECT_NAME  ,OBJECT_ID  ,DATA_OBJECT_ID  ,OBJECT_TYPE  ,CREATED  ,LAST_DDL_TIME  ,TIMESTAMP  ,STATUS  ,TEMPORARY  ,GENERATED FROM SYSIBMADM.DBA_OBJECTS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_PART_INDEXES" ("INDEX_SCHEMA", "INDEX_NAME", "TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING") AS
SELECT   INDEX_SCHEMA  ,INDEX_NAME  ,TABLE_SCHEMA  ,TABLE_NAME  ,PARTITIONING_TYPE  ,SUBPARTITIONING_TYPE  ,PARTITION_COUNT  ,PARTITIONING_KEY_COUNT  ,DEF_PCT_FREE  ,DEF_PCT_INCREASE  ,DEF_LOGGING FROM SYSIBMADM.DBA_PART_INDEXES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_PART_KEY_COLUMNS" ("OBJECT_SCHEMA", "OBJECT_NAME", "OBJECT_TYPE", "COLUMN_NAME", "COLUMN_POSITION") AS
SELECT   OBJECT_SCHEMA  ,OBJECT_NAME  ,OBJECT_TYPE  ,COLUMN_NAME  ,COLUMN_POSITION FROM SYSIBMADM.DBA_PART_KEY_COLUMNS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_PART_TABLES" ("TABLE_SCHEMA", "TABLE_NAME", "PARTITIONING_TYPE", "SUBPARTITIONING_TYPE", "PARTITION_COUNT", "PARTITIONING_KEY_COUNT", "DEF_PCT_FREE", "DEF_PCT_INCREASE", "DEF_LOGGING", "DEF_COMPRESSION") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,PARTITIONING_TYPE  ,SUBPARTITIONING_TYPE  ,PARTITION_COUNT  ,PARTITIONING_KEY_COUNT  ,DEF_PCT_FREE  ,DEF_PCT_INCREASE  ,DEF_LOGGING  ,DEF_COMPRESSION FROM SYSIBMADM.DBA_PART_TABLES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_PROCEDURES" ("OBJECT_SCHEMA", "OBJECT_NAME", "PROCEDURE_SCHEMA", "PROCEDURE_NAME", "PROCEDURE_SPECIFIC_NAME", "AGGREGATE", "PARALLEL") AS
SELECT   OBJECT_SCHEMA  ,OBJECT_NAME  ,PROCEDURE_SCHEMA  ,PROCEDURE_NAME  ,PROCEDURE_SPECIFIC_NAME  ,AGGREGATE  ,PARALLEL FROM SYSIBMADM.DBA_PROCEDURES WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_SEQUENCES" ("SEQUENCE_SCHEMA", "SEQUENCE_NAME", "MIN_VALUE", "MAX_VALUE", "INCREMENT_BY", "CYCLE_FLAG", "ORDER_FLAG", "CACHE_SIZE", "LAST_NUMBER") AS
SELECT   SEQUENCE_SCHEMA  ,SEQUENCE_NAME  ,MIN_VALUE  ,MAX_VALUE  ,INCREMENT_BY  ,CYCLE_FLAG  ,ORDER_FLAG  ,CACHE_SIZE  ,LAST_NUMBER FROM SYSIBMADM.DBA_SEQUENCES WHERE SEQUENCE_OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_SOURCE" ("SCHEMA", "NAME", "SPECIFICNAME", "TYPE", "TEXT") AS
SELECT   SCHEMA  ,NAME  ,SPECIFICNAME  ,TYPE  ,TEXT FROM SYSIBMADM.DBA_SOURCE WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_SYNONYMS" ("SYNONYM_SCHEMA", "SYNONYM_NAME", "TABLE_OWNER", "TABLE_SCHEMA", "TABLE_NAME") AS
SELECT   SYNONYM_SCHEMA  ,SYNONYM_NAME  ,TABLE_OWNER  ,TABLE_SCHEMA  ,TABLE_NAME FROM SYSIBMADM.DBA_SYNONYMS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TABLESPACES" ("TABLESPACE_NAME", "DBPARTITIONNUM", "BLOCK_SIZE", "INITIAL_EXTENT", "NEXT_EXTENT", "MIN_EXTENTS", "MAX_EXTENTS", "PCT_INCREASE", "MIN_EXTLEN", "STATUS", "CONTENTS", "LOGGING", "SEGMENT_SPACE_MANAGEMENT") AS
SELECT TS.* FROM SYSIBMADM.DBA_TABLESPACES TS, SYSCAT.TBSPACEAUTH AUTH WHERE TS.TABLESPACE_NAME = AUTH.TBSPACE AND      AUTH.GRANTEE = CURRENT USER AND AUTH.USEAUTH != 'N';

CREATE VIEW "SYSIBMADM"."USER_TAB_COLUMNS" ("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_TYPE_OWNER", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "NULLABLE", "COLUMN_ID", "DEFAULT_LENGTH", "DATA_DEFAULT", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "CHAR_COL_DECL_LENGTH", "GLOBAL_STATS", "AVG_COL_LEN", "CHAR_LENGTH", "CHAR_USED") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,COLUMN_NAME  ,DATA_TYPE  ,DATA_TYPE_OWNER  ,DATA_LENGTH  ,DATA_PRECISION  ,DATA_SCALE  ,NULLABLE  ,COLUMN_ID  ,DEFAULT_LENGTH  ,DATA_DEFAULT  ,NUM_DISTINCT  ,NUM_NULLS  ,LAST_ANALYZED  ,CHAR_COL_DECL_LENGTH  ,GLOBAL_STATS  ,AVG_COL_LEN  ,CHAR_LENGTH  ,CHAR_USED FROM SYSIBMADM.DBA_TAB_COLUMNS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_COL_STATISTICS" ("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "NUM_DISTINCT", "NUM_NULLS", "LAST_ANALYZED", "GLOBAL_STATS", "AVG_COL_LEN") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,COLUMN_NAME  ,NUM_DISTINCT  ,NUM_NULLS  ,LAST_ANALYZED  ,GLOBAL_STATS  ,AVG_COL_LEN FROM SYSIBMADM.DBA_TAB_COL_STATISTICS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_COMMENTS" ("TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE", "COMMENTS") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,TABLE_TYPE  ,COMMENTS FROM SYSIBMADM.DBA_TAB_COMMENTS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_PARTITIONS" ("TABLE_SCHEMA", "TABLE_NAME", "PARTITION_NAME", "HIGH_VALUE", "HIGH_VALUE_LENGTH", "PARTITION_POSITION", "TABLESPACE_NAME", "PCT_FREE", "INITIAL_EXTENT", "NEXT_EXTENT", "PCT_INCREASE", "LOGGING", "COMPRESSION", "AVG_ROW_LEN", "LAST_ANALYZED", "BUFFER_POOL", "GLOBAL_STATS") AS
SELECT   TABLE_SCHEMA  ,TABLE_NAME  ,PARTITION_NAME  ,HIGH_VALUE  ,HIGH_VALUE_LENGTH  ,PARTITION_POSITION  ,TABLESPACE_NAME  ,PCT_FREE  ,INITIAL_EXTENT  ,NEXT_EXTENT  ,PCT_INCREASE  ,LOGGING  ,COMPRESSION  ,AVG_ROW_LEN  ,LAST_ANALYZED  ,BUFFER_POOL  ,GLOBAL_STATS FROM SYSIBMADM.DBA_TAB_PARTITIONS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_PRIVS" ("GRANTEE", "OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT * FROM SYSIBMADM.DBA_TAB_PRIVS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_PRIVS_MADE" ("GRANTEE", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT   GRANTEE  ,TABLE_SCHEMA  ,TABLE_NAME  ,GRANTOR  ,PRIVILEGE  ,GRANTABLE FROM SYSIBMADM.DBA_TAB_PRIVS PRIV WHERE PRIV.OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TAB_PRIVS_RECD" ("OWNER", "TABLE_SCHEMA", "TABLE_NAME", "GRANTOR", "PRIVILEGE", "GRANTABLE") AS
SELECT   OWNER  ,TABLE_SCHEMA  ,TABLE_NAME  ,GRANTOR  ,PRIVILEGE  ,GRANTABLE FROM SYSIBMADM.DBA_TAB_PRIVS PRIV WHERE PRIV.GRANTEE = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_TRIGGERS" ("TRIGGER_SCHEMA", "TRIGGER_NAME", "TRIGGER_TYPE", "TRIGGERING_EVENT", "TABLE_OWNER", "BASE_OBJECT_TYPE", "TABLE_SCHEMA", "TABLE_NAME", "STATUS", "TRIGGER_BODY") AS
SELECT   TRIGGER_SCHEMA  ,TRIGGER_NAME  ,TRIGGER_TYPE  ,TRIGGERING_EVENT  ,TABLE_OWNER  ,BASE_OBJECT_TYPE  ,TABLE_SCHEMA  ,TABLE_NAME  ,STATUS  ,TRIGGER_BODY FROM SYSIBMADM.DBA_TRIGGERS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_VIEWS" ("VIEW_SCHEMA", "VIEW_NAME", "TEXT_LENGTH", "TEXT") AS
SELECT   VIEW_SCHEMA  ,VIEW_NAME  ,TEXT_LENGTH  ,TEXT FROM SYSIBMADM.DBA_VIEWS WHERE OWNER = CURRENT USER;

CREATE VIEW "SYSIBMADM"."USER_VIEW_COLUMNS" ("OWNER", "VIEW_SCHEMA", "VIEW_NAME", "COLUMN_NAME", "DATA_TYPE", "DATA_LENGTH", "DATA_PRECISION", "DATA_SCALE", "COLUMN_ID", "NULLABLE", "DATA_DEFAULT") AS
SELECT * FROM SYSIBMADM.DBA_VIEW_COLUMNS WHERE OWNER = CURRENT USER;

CREATE ALIAS "SYSPUBLIC"."ALL_ALL_TABLES" FOR "SYSIBMADM"."ALL_ALL_TABLES";

CREATE ALIAS "SYSPUBLIC"."ALL_ARGUMENTS" FOR "SYSIBMADM"."ALL_ARGUMENTS";

CREATE ALIAS "SYSPUBLIC"."ALL_CATALOG" FOR "SYSIBMADM"."ALL_CATALOG";

CREATE ALIAS "SYSPUBLIC"."ALL_COL_COMMENTS" FOR "SYSIBMADM"."ALL_COL_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."ALL_CONSTRAINTS" FOR "SYSIBMADM"."ALL_CONSTRAINTS";

CREATE ALIAS "SYSPUBLIC"."ALL_CONS_COLUMNS" FOR "SYSIBMADM"."ALL_CONS_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."ALL_DEPENDENCIES" FOR "SYSIBMADM"."ALL_DEPENDENCIES";

CREATE ALIAS "SYSPUBLIC"."ALL_ERRORS" FOR "SYSIBMADM"."ALL_ERRORS";

CREATE ALIAS "SYSPUBLIC"."ALL_INDEXES" FOR "SYSIBMADM"."ALL_INDEXES";

CREATE ALIAS "SYSPUBLIC"."ALL_IND_COLUMNS" FOR "SYSIBMADM"."ALL_IND_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."ALL_IND_PARTITIONS" FOR "SYSIBMADM"."ALL_IND_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."ALL_OBJECTS" FOR "SYSIBMADM"."ALL_OBJECTS";

CREATE ALIAS "SYSPUBLIC"."ALL_PART_INDEXES" FOR "SYSIBMADM"."ALL_PART_INDEXES";

CREATE ALIAS "SYSPUBLIC"."ALL_PART_KEY_COLUMNS" FOR "SYSIBMADM"."ALL_PART_KEY_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."ALL_PART_TABLES" FOR "SYSIBMADM"."ALL_PART_TABLES";

CREATE ALIAS "SYSPUBLIC"."ALL_PROCEDURES" FOR "SYSIBMADM"."ALL_PROCEDURES";

CREATE ALIAS "SYSPUBLIC"."ALL_SEQUENCES" FOR "SYSIBMADM"."ALL_SEQUENCES";

CREATE ALIAS "SYSPUBLIC"."ALL_SOURCE" FOR "SYSIBMADM"."ALL_SOURCE";

CREATE ALIAS "SYSPUBLIC"."ALL_SYNONYMS" FOR "SYSIBMADM"."ALL_SYNONYMS";

CREATE ALIAS "SYSPUBLIC"."ALL_TABLES" FOR "SYSIBMADM"."ALL_TABLES";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_COLUMNS" FOR "SYSIBMADM"."ALL_TAB_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_COL_STATISTICS" FOR "SYSIBMADM"."ALL_TAB_COL_STATISTICS";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_COMMENTS" FOR "SYSIBMADM"."ALL_TAB_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_PARTITIONS" FOR "SYSIBMADM"."ALL_TAB_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_PRIVS" FOR "SYSIBMADM"."ALL_TAB_PRIVS";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_PRIVS_MADE" FOR "SYSIBMADM"."ALL_TAB_PRIVS_MADE";

CREATE ALIAS "SYSPUBLIC"."ALL_TAB_PRIVS_RECD" FOR "SYSIBMADM"."ALL_TAB_PRIVS_RECD";

CREATE ALIAS "SYSPUBLIC"."ALL_TRIGGERS" FOR "SYSIBMADM"."ALL_TRIGGERS";

CREATE ALIAS "SYSPUBLIC"."ALL_VIEWS" FOR "SYSIBMADM"."ALL_VIEWS";

CREATE ALIAS "SYSPUBLIC"."ALL_VIEW_COLUMNS" FOR "SYSIBMADM"."ALL_VIEW_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."CAT" FOR "SYSIBMADM"."USER_CATALOG";

CREATE ALIAS "SYSPUBLIC"."COLS" FOR "SYSIBMADM"."USER_TAB_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DBA_ALL_TABLES" FOR "SYSIBMADM"."DBA_ALL_TABLES";

CREATE ALIAS "SYSPUBLIC"."DBA_ARGUMENTS" FOR "SYSIBMADM"."DBA_ARGUMENTS";

CREATE ALIAS "SYSPUBLIC"."DBA_CATALOG" FOR "SYSIBMADM"."DBA_CATALOG";

CREATE ALIAS "SYSPUBLIC"."DBA_COL_COMMENTS" FOR "SYSIBMADM"."DBA_COL_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."DBA_CONSTRAINTS" FOR "SYSIBMADM"."DBA_CONSTRAINTS";

CREATE ALIAS "SYSPUBLIC"."DBA_CONS_COLUMNS" FOR "SYSIBMADM"."DBA_CONS_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DBA_DEPENDENCIES" FOR "SYSIBMADM"."DBA_DEPENDENCIES";

CREATE ALIAS "SYSPUBLIC"."DBA_ERRORS" FOR "SYSIBMADM"."DBA_ERRORS";

CREATE ALIAS "SYSPUBLIC"."DBA_INDEXES" FOR "SYSIBMADM"."DBA_INDEXES";

CREATE ALIAS "SYSPUBLIC"."DBA_IND_COLUMNS" FOR "SYSIBMADM"."DBA_IND_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DBA_IND_PARTITIONS" FOR "SYSIBMADM"."DBA_IND_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."DBA_OBJECTS" FOR "SYSIBMADM"."DBA_OBJECTS";

CREATE ALIAS "SYSPUBLIC"."DBA_PART_INDEXES" FOR "SYSIBMADM"."DBA_PART_INDEXES";

CREATE ALIAS "SYSPUBLIC"."DBA_PART_KEY_COLUMNS" FOR "SYSIBMADM"."DBA_PART_KEY_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DBA_PART_TABLES" FOR "SYSIBMADM"."DBA_PART_TABLES";

CREATE ALIAS "SYSPUBLIC"."DBA_PROCEDURES" FOR "SYSIBMADM"."DBA_PROCEDURES";

CREATE ALIAS "SYSPUBLIC"."DBA_ROLES" FOR "SYSIBMADM"."DBA_ROLES";

CREATE ALIAS "SYSPUBLIC"."DBA_ROLE_PRIVS" FOR "SYSIBMADM"."DBA_ROLE_PRIVS";

CREATE ALIAS "SYSPUBLIC"."DBA_SEQUENCES" FOR "SYSIBMADM"."DBA_SEQUENCES";

CREATE ALIAS "SYSPUBLIC"."DBA_SOURCE" FOR "SYSIBMADM"."DBA_SOURCE";

CREATE ALIAS "SYSPUBLIC"."DBA_SYNONYMS" FOR "SYSIBMADM"."DBA_SYNONYMS";

CREATE ALIAS "SYSPUBLIC"."DBA_SYS_PRIVS" FOR "SYSIBMADM"."DBA_SYS_PRIVS";

CREATE ALIAS "SYSPUBLIC"."DBA_TABLES" FOR "SYSIBMADM"."DBA_TABLES";

CREATE ALIAS "SYSPUBLIC"."DBA_TABLESPACES" FOR "SYSIBMADM"."DBA_TABLESPACES";

CREATE ALIAS "SYSPUBLIC"."DBA_TAB_COLUMNS" FOR "SYSIBMADM"."DBA_TAB_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DBA_TAB_COL_STATISTICS" FOR "SYSIBMADM"."DBA_TAB_COL_STATISTICS";

CREATE ALIAS "SYSPUBLIC"."DBA_TAB_COMMENTS" FOR "SYSIBMADM"."DBA_TAB_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."DBA_TAB_PARTITIONS" FOR "SYSIBMADM"."DBA_TAB_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."DBA_TAB_PRIVS" FOR "SYSIBMADM"."DBA_TAB_PRIVS";

CREATE ALIAS "SYSPUBLIC"."DBA_TRIGGERS" FOR "SYSIBMADM"."DBA_TRIGGERS";

CREATE ALIAS "SYSPUBLIC"."DBA_VIEWS" FOR "SYSIBMADM"."DBA_VIEWS";

CREATE ALIAS "SYSPUBLIC"."DBA_VIEW_COLUMNS" FOR "SYSIBMADM"."DBA_VIEW_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DICT" FOR "SYSIBMADM"."DICTIONARY";

CREATE ALIAS "SYSPUBLIC"."DICTIONARY" FOR "SYSIBMADM"."DICTIONARY";

CREATE ALIAS "SYSPUBLIC"."DICT_COLUMNS" FOR "SYSIBMADM"."DICT_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."DUAL" FOR "SYSIBM"."DUAL";

CREATE ALIAS "SYSPUBLIC"."IND" FOR "SYSIBMADM"."USER_INDEXES";

CREATE ALIAS "SYSPUBLIC"."OBJ" FOR "SYSIBMADM"."USER_OBJECTS";

CREATE ALIAS "SYSPUBLIC"."ROLE_ROLE_PRIVS" FOR "SYSIBMADM"."ROLE_ROLE_PRIVS";

CREATE ALIAS "SYSPUBLIC"."ROLE_SYS_PRIVS" FOR "SYSIBMADM"."ROLE_SYS_PRIVS";

CREATE ALIAS "SYSPUBLIC"."ROLE_TAB_PRIVS" FOR "SYSIBMADM"."ROLE_TAB_PRIVS";

CREATE ALIAS "SYSPUBLIC"."SEQ" FOR "SYSIBMADM"."USER_SEQUENCES";

CREATE ALIAS "SYSPUBLIC"."SESSION_PRIVS" FOR "SYSIBMADM"."SESSION_PRIVS";

CREATE ALIAS "SYSPUBLIC"."SESSION_ROLES" FOR "SYSIBMADM"."SESSION_ROLES";

CREATE ALIAS "SYSPUBLIC"."SIN" FOR "SYSIBMADM"."USER_SYNONYMS";

CREATE ALIAS "SYSPUBLIC"."TAB" FOR "SYSIBMADM"."TAB";

CREATE ALIAS "SYSPUBLIC"."TABS" FOR "SYSIBMADM"."USER_TABLES";

CREATE ALIAS "SYSPUBLIC"."USER_ALL_TABLES" FOR "SYSIBMADM"."USER_ALL_TABLES";

CREATE ALIAS "SYSPUBLIC"."USER_ARGUMENTS" FOR "SYSIBMADM"."USER_ARGUMENTS";

CREATE ALIAS "SYSPUBLIC"."USER_CATALOG" FOR "SYSIBMADM"."USER_CATALOG";

CREATE ALIAS "SYSPUBLIC"."USER_COL_COMMENTS" FOR "SYSIBMADM"."USER_COL_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."USER_CONSTRAINTS" FOR "SYSIBMADM"."USER_CONSTRAINTS";

CREATE ALIAS "SYSPUBLIC"."USER_CONS_COLUMNS" FOR "SYSIBMADM"."USER_CONS_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."USER_DEPENDENCIES" FOR "SYSIBMADM"."USER_DEPENDENCIES";

CREATE ALIAS "SYSPUBLIC"."USER_ERRORS" FOR "SYSIBMADM"."USER_ERRORS";

CREATE ALIAS "SYSPUBLIC"."USER_INDEXES" FOR "SYSIBMADM"."USER_INDEXES";

CREATE ALIAS "SYSPUBLIC"."USER_IND_COLUMNS" FOR "SYSIBMADM"."USER_IND_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."USER_IND_PARTITIONS" FOR "SYSIBMADM"."USER_IND_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."USER_OBJECTS" FOR "SYSIBMADM"."USER_OBJECTS";

CREATE ALIAS "SYSPUBLIC"."USER_PART_INDEXES" FOR "SYSIBMADM"."USER_PART_INDEXES";

CREATE ALIAS "SYSPUBLIC"."USER_PART_KEY_COLUMNS" FOR "SYSIBMADM"."USER_PART_KEY_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."USER_PART_TABLES" FOR "SYSIBMADM"."USER_PART_TABLES";

CREATE ALIAS "SYSPUBLIC"."USER_PROCEDURES" FOR "SYSIBMADM"."USER_PROCEDURES";

CREATE ALIAS "SYSPUBLIC"."USER_ROLE_PRIVS" FOR "SYSIBMADM"."USER_ROLE_PRIVS";

CREATE ALIAS "SYSPUBLIC"."USER_SEQUENCES" FOR "SYSIBMADM"."USER_SEQUENCES";

CREATE ALIAS "SYSPUBLIC"."USER_SOURCE" FOR "SYSIBMADM"."USER_SOURCE";

CREATE ALIAS "SYSPUBLIC"."USER_SYNONYMS" FOR "SYSIBMADM"."USER_SYNONYMS";

CREATE ALIAS "SYSPUBLIC"."USER_SYS_PRIVS" FOR "SYSIBMADM"."USER_SYS_PRIVS";

CREATE ALIAS "SYSPUBLIC"."USER_TABLES" FOR "SYSIBMADM"."USER_TABLES";

CREATE ALIAS "SYSPUBLIC"."USER_TABLESPACES" FOR "SYSIBMADM"."USER_TABLESPACES";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_COLUMNS" FOR "SYSIBMADM"."USER_TAB_COLUMNS";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_COL_STATISTICS" FOR "SYSIBMADM"."USER_TAB_COL_STATISTICS";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_COMMENTS" FOR "SYSIBMADM"."USER_TAB_COMMENTS";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_PARTITIONS" FOR "SYSIBMADM"."USER_TAB_PARTITIONS";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_PRIVS" FOR "SYSIBMADM"."USER_TAB_PRIVS";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_PRIVS_MADE" FOR "SYSIBMADM"."USER_TAB_PRIVS_MADE";

CREATE ALIAS "SYSPUBLIC"."USER_TAB_PRIVS_RECD" FOR "SYSIBMADM"."USER_TAB_PRIVS_RECD";

CREATE ALIAS "SYSPUBLIC"."USER_TRIGGERS" FOR "SYSIBMADM"."USER_TRIGGERS";

CREATE ALIAS "SYSPUBLIC"."USER_VIEWS" FOR "SYSIBMADM"."USER_VIEWS";

CREATE ALIAS "SYSPUBLIC"."USER_VIEW_COLUMNS" FOR "SYSIBMADM"."USER_VIEW_COLUMNS";

CREATE VIEW "SYSSTAT"."COLDIST" ("TABSCHEMA", "TABNAME", "COLNAME", "TYPE", "SEQNO", "COLVALUE", "VALCOUNT", "DISTCOUNT") AS
select 
schema, tbname, name, type, seqno, colvalue, valcount, 
distcount 
from sysibm.syscoldist X 
where exists 
(select 1 from sysibm.systabauth 
where ttname = X.tbname 
and tcreator = X.schema 
and grantee = USER 
and controlauth = 'Y') 
or exists 
(select 1 from sysibm.sysdbauth 
where grantee = USER 
and dataaccessauth = 'Y');

CREATE VIEW "SYSSTAT"."COLGROUPDIST" ("COLGROUPID", "TYPE", "ORDINAL", "SEQNO", "COLVALUE") AS
select 
colgroupid, type, ordinal, seqno, colvalue 
from sysibm.syscolgroupdist;

CREATE VIEW "SYSSTAT"."COLGROUPDISTCOUNTS" ("COLGROUPID", "TYPE", "SEQNO", "VALCOUNT", "DISTCOUNT") AS
select 
colgroupid, type, seqno, valcount, distcount 
from sysibm.syscolgroupdistcounts;

CREATE VIEW "SYSSTAT"."COLGROUPS" ("COLGROUPSCHEMA", "COLGROUPNAME", "COLGROUPID", "COLGROUPCARD", "NUMFREQ_VALUES", "NUMQUANTILES", "NUMQUANTILE") AS
select 
colgroupschema, colgroupname, colgroupid, colgroupcard, 
numfreq_values, numquantiles, numquantiles 
from sysibm.syscolgroups;

CREATE VIEW "SYSSTAT"."COLUMNS" ("TABSCHEMA", "TABNAME", "COLNAME", "COLCARD", "HIGH2KEY", "LOW2KEY", "AVGCOLLEN", "NUMNULLS", "PCTINLINED", "SUB_COUNT", "SUB_DELIM_LENGTH", "AVGCOLLENCHAR") AS
select 
tbcreator, tbname, name, colcard, high2key, low2key, 
avgcollen, numnulls, pctinlined, sub_count, sub_delim_length, avgcollenchar 
from sysibm.syscolumns X 
where( (source_tabschema = tbcreator and 
source_tabname = tbname) or 
(source_tabschema IS NULL and 
source_tabname IS NULL) ) 
and exists 
(select 1 
from   sysibm.systables 
where  name = X.tbname 
and    creator = X.tbcreator 
and    (type not in ('A', 'V', 'W', 'H', 'K') or 
(type = 'V' and substr(property, 13, 1) = 'Y') ) ) 
and (exists 
(select 1 from   sysibm.systabauth 
where  ttname = X.tbname 
and    tcreator = X.tbcreator 
and    grantee = USER 
and    controlauth = 'Y') 
or exists 
(select 1 from   sysibm.sysdbauth 
where  grantee = USER 
and    dataaccessauth = 'Y') );

CREATE VIEW "SYSSTAT"."FUNCTIONS" ("FUNCSCHEMA", "FUNCNAME", "SPECIFICNAME", "IOS_PER_INVOC", "INSTS_PER_INVOC", "IOS_PER_ARGBYTE", "INSTS_PER_ARGBYTE", "PERCENT_ARGBYTES", "INITIAL_IOS", "INITIAL_INSTS", "CARDINALITY", "SELECTIVITY") AS
select 
routineschema, routinename, specificname, ios_per_invoc, 
insts_per_invoc, ios_per_argbyte, insts_per_argbyte, 
percent_argbytes, initial_ios, initial_insts, 
cardinality, selectivity 
from sysibm.sysroutines 
where 
routinemoduleid is null and 
( routinetype in ('F', 'M') and 
routineschema not in ('SYSIBMINTERNAL') and 
( routineschema = USER or 
EXISTS 
( select 1 
from sysibm.sysdbauth 
where grantee = USER and ( dbadmauth = 'Y' or sqladmauth ='Y' ) ) ) );

CREATE VIEW "SYSSTAT"."INDEXES" ("INDSCHEMA", "INDNAME", "TABSCHEMA", "TABNAME", "COLNAMES", "NLEAF", "NLEVELS", "FIRSTKEYCARD", "FIRST2KEYCARD", "FIRST3KEYCARD", "FIRST4KEYCARD", "FULLKEYCARD", "CLUSTERRATIO", "CLUSTERFACTOR", "SEQUENTIAL_PAGES", "DENSITY", "PAGE_FETCH_PAIRS", "NUMRIDS", "NUMRIDS_DELETED", "NUM_EMPTY_LEAFS", "AVERAGE_RANDOM_FETCH_PAGES", "AVERAGE_RANDOM_PAGES", "AVERAGE_SEQUENCE_GAP", "AVERAGE_SEQUENCE_FETCH_GAP", "AVERAGE_SEQUENCE_PAGES", "AVERAGE_SEQUENCE_FETCH_PAGES", "AVGPARTITION_CLUSTERRATIO", "AVGPARTITION_CLUSTERFACTOR", "AVGPARTITION_PAGE_FETCH_PAIRS", "DATAPARTITION_CLUSTERFACTOR", "INDCARD", "PCTPAGESSAVED", "AVGLEAFKEYSIZE", "AVGNLEAFKEYSIZE") AS
select 
creator, name, tbcreator, tbname, colnames, nleaf, 
nlevels, firstkeycard, first2keycard, first3keycard, 
first4keycard, fullkeycard, clusterratio, clusterfactor, 
sequential_pages, density, page_fetch_pairs, 
numrids, numrids_deleted, num_empty_leafs, 
average_random_fetch_pages, average_random_pages, 
average_sequence_gap, average_sequence_fetch_gap, 
average_sequence_pages, average_sequence_fetch_pages, 
avgpartition_clusterratio, avgpartition_clusterfactor, 
avgpartition_page_fetch_pairs, 
datapartition_clusterfactor, indcard, pctpagessaved, 
avgleafkeysize, avgnleafkeysize 
from sysibm.sysindexes X 
where x.entrytype <> 'H' 
and x.indextype <> 'XVIL' 
and (exists 
(select 1 
from sysibm.sysindexauth 
where creator = X.creator 
and name = X.name 
and grantee = USER 
and controlauth = 'Y' ) 
or exists 
(select 1 
from sysibm.sysdbauth 
where  grantee = USER 
and dataaccessauth = 'Y') 
or exists 
(select 1 from sysibm.sysindexauth XA, sysibm.sysindexxmlpatterns XP 
where X.name = XP.pindname 
and XA.name = XP.indname 
and XA.creator = XP.indschema 
and XA.grantee = USER 
and XA.controlauth = 'Y') 
);

CREATE VIEW "SYSSTAT"."ROUTINES" ("ROUTINESCHEMA", "ROUTINEMODULENAME", "ROUTINENAME", "ROUTINETYPE", "SPECIFICNAME", "IOS_PER_INVOC", "INSTS_PER_INVOC", "IOS_PER_ARGBYTE", "INSTS_PER_ARGBYTE", "PERCENT_ARGBYTES", "INITIAL_IOS", "INITIAL_INSTS", "CARDINALITY", "SELECTIVITY") AS
select 
routineschema, 
(select modulename from sysibm.sysmodules where moduleid = routinemoduleid), 
routinename, routinetype, specificname, ios_per_invoc, 
insts_per_invoc, ios_per_argbyte, insts_per_argbyte, percent_argbytes, 
initial_ios, initial_insts, cardinality, selectivity 
from sysibm.sysroutines 
where 
routinemoduleid is null and 
(  routineschema = USER OR 
definer = USER OR 
routineschema not in ('SYSIBMINTERNAL') AND 
exists 
( 
select 1 
from sysibm.sysdbauth 
where grantee = USER and ( dbadmauth = 'Y' or sqladmauth = 'Y' ) 
) );

CREATE VIEW "SYSSTAT"."TABLES" ("TABSCHEMA", "TABNAME", "CARD", "NPAGES", "FPAGES", "OVERFLOW", "CLUSTERED", "ACTIVE_BLOCKS", "AVGCOMPRESSEDROWSIZE", "AVGROWCOMPRESSIONRATIO", "AVGROWSIZE", "PCTROWSCOMPRESSED", "PCTPAGESSAVED") AS
select 
creator, name, card, npages, fpages, overflow, 
clustered, active_blocks, avgcompressedrowsize, avgrowcompressionratio, 
avgrowsize, pctrowscompressed, pctpagessaved 
from sysibm.systables X 
where (X.type not in ('A', 'V', 'W', 'H', 'K') 
or (X.type = 'V' and substr(X.property, 13, 1) = 'Y')) 
and (exists 
(select 1 
from   sysibm.systabauth ta 
where  ta.tcreator = X.creator 
and    ta.ttname = X.name 
and    ta.grantee = USER 
and    ta.controlauth = 'Y' ) 
or exists 
(select 1 
from   sysibm.sysdbauth da 
where  da.grantee = USER 
and    da.dataaccessauth = 'Y') );

CREATE FUNCTION "SYSCAT"."COLLATIONNAME" (CHAR (8) FOR BIT DATA)
	RETURNS VARCHAR(128)
	SPECIFIC "SYSCAT"."SYSCAT_COLLATIONNAME"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCOLLATIONNAME"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSFUN"."ABS" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."ABS4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABS" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ABS1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABS" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ABS2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABS" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."ABS3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABSVAL" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."ABSVAL4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABSVAL" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ABSVAL1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABSVAL" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ABSVAL2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ABSVAL" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."ABSVAL3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfABS3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ACOS" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ACOS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfACOS"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."APPLICATION_ID" ()
	RETURNS VARCHAR(128)
	SPECIFIC "SYSFUN"."APPLICATION_ID"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!application_id"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSFUN"."ASCII" (CHAR(254))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ASCII1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfASCII1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ASCII" (CLOB(1048576))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ASCII3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfASCII3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ASCII" (VARCHAR(4000))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ASCII2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfASCII2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ASIN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ASIN"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfASIN"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ATAN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ATAN"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfATAN"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ATAN2" (DOUBLE, 
		DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ATAN2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfATAN2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEIL" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."CEIL4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEIL" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."CEIL1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEIL" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."CEIL2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEIL" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."CEIL3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEILING" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."CEILING4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEILING" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."CEILING1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEILING" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."CEILING2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CEILING" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."CEILING3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCEILING3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CHAR" (DOUBLE)
	RETURNS CHAR(24)
	SPECIFIC "SYSFUN"."DOUBLETOCHAR"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDOUBLETOCHAR"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."CHR" (INTEGER)
	RETURNS CHAR(1)
	SPECIFIC "SYSFUN"."CHR"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCHAR"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."COS" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."COS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCOS"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."COT" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."COT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCOT"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYNAME" (DATE)
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."DAYNAME2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYNAME2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYNAME" (TIMESTAMP)
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."DAYNAME3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYNAME1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYNAME" (VARCHAR(32))
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."DAYNAME1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYNAME1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK_ISO" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK_ISO2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK_ISO2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK_ISO" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK_ISO3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK_ISO1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFWEEK_ISO" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFWEEK_ISO1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFWEEK_ISO1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFYEAR" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFYEAR1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFYEAR1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFYEAR" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFYEAR2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFYEAR2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DAYOFYEAR" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DAYOFYEAR3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDAYOFYEAR2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DEGREES" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."DEGREES1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDEGREES1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DIFFERENCE" (VARCHAR(4000), 
		VARCHAR(4000))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."DIFFERENCE"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfDIFFERENCE"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."DOUBLE" (VARCHAR(4000))
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."CHARTODOUBLE"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfCHARTODOUBLE"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."EXP" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."EXP"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfEXP"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."FLOOR" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."FLOOR4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFLOOR4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."FLOOR" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."FLOOR1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFLOOR1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."FLOOR" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."FLOOR2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFLOOR2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."FLOOR" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."FLOOR3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFLOOR3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."FMPROWS" ()
	RETURNS TABLE (FMPPID INTEGER,  STATEFLAGS INTEGER,  NUMACTIVETHREADS SMALLINT,  NUMPOOLTHREADS SMALLINT,  ACTIVE SMALLINT,  ROWLOADERVALIDATE SMALLINT)
	SPECIFIC "SYSFUN"."SQL120427015508700"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFmpRows"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."FMPTHREADS" (INTEGER)
	RETURNS TABLE (THREADID INTEGER,  AGENTPID INTEGER,  USECOUNT INTEGER,  NESTLEVEL INTEGER,  REFRESHTHREADCLASS INTEGER,  ASSOCBROKEN INTEGER)
	SPECIFIC "SYSFUN"."SQL120427015508701"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfFmpThreads"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."GET_DBM_CONFIG" ()
	RETURNS TABLE (DBMCONFIG_TYPE INTEGER,  AGENT_STACK_SZ INTEGER,  AGENTPRI INTEGER,  ASLHEAPSZ INTEGER,  AUDIT_BUF_SZ INTEGER,  AUTHENTICATION INTEGER,  BACKBUFSZ INTEGER,  CATALOG_NOAUTH INTEGER,  COMM_BANDWIDTH REAL,  CONN_ELAPSE INTEGER,  CPUSPEED REAL,  DATALINKS INTEGER,  DFT_ACCOUNT_STR VARCHAR(25),  DFT_CLIENT_ADPT INTEGER,  DFT_CLIENT_COMM VARCHAR(31),  DFT_MONSWITCHES INTEGER,  DFT_MON_BUFPOOL INTEGER,  DFT_MON_LOCK INTEGER,  DFT_MON_SORT INTEGER,  DFT_MON_STMT INTEGER,  DFT_MON_TABLE INTEGER,  DFT_MON_UOW INTEGER,  DFTDBPATH VARCHAR(215),  DIAGLEVEL INTEGER,  DIAGPATH VARCHAR(215),  DIR_CACHE INTEGER,  DIR_OBJ_NAME VARCHAR(255),  DIR_PATH_NAME VARCHAR(255),  DIR_TYPEC INTEGER,  DISCOVERD INTEGER,  DISCOVER_COMM VARCHAR(35),  DISCOVER_INST INTEGER,  DOS_RQRIOBLK INTEGER,  DRDA_HEAP_SZ INTEGER,  FCM_NUM_ANCHORS INTEGER,  FCM_NUM_BUFFERS INTEGER,  FCM_NUM_CONNECT INTEGER,  FCM_NUM_RQB INTEGER,  FEDERATED INTEGER,  FILESERVER VARCHAR(48),  INDEXRECE INTEGER,  INITDARI_JVM INTEGER,  INTRA_PARALLEL INTEGER,  IPX_SOCKET VARCHAR(4),  JAVA_HEAP_SZ INTEGER,  JDK11_PATH VARCHAR(255),  KEEPDARI INTEGER,  MAX_CONNRETRIES INTEGER,  MAX_COORDAGENTS INTEGER,  MAX_LOGICAGENTS INTEGER,  MAX_QUERYDEGREE INTEGER,  MAX_TIME_DIFF INTEGER,  MAXAGENTS INTEGER,  MAXCAGENTS INTEGER,  MAXDARI INTEGER,  MAXTOTFILOP INTEGER,  MIN_PRIV_MEM INTEGER,  MON_HEAP_SZ INTEGER,  NNAME VARCHAR(8),  NOTIFYLEVEL INTEGER,  NUM_INITAGENTS INTEGER,  NUM_INITDARIS INTEGER,  NUM_POOLAGENTS INTEGER,  NUMDB INTEGER,  OBJECTNAME VARCHAR(48),  PRIV_MEM_THRESH INTEGER,  QUERY_HEAP_SZ INTEGER,  RESTBUFSZ INTEGER,  RESYNC_INTERVAL INTEGER,  ROUTE_OBJ_NAME VARCHAR(255),  RQRIOBLK INTEGER,  SHEAPTHRES INTEGER,  SPM_LOG_FILE_SZ INTEGER,  SPM_MAX_RESYNC INTEGER,  SPM_NAME VARCHAR(8),  SPM_PATH_NAME VARCHAR(226),  SS_LOGON INTEGER,  START_STOP_TIME INTEGER,  SVCENAME VARCHAR(14),  SYSADM_GROUP VARCHAR(16),  SYSCTRL_GROUP VARCHAR(16),  SYSMAINT_GROUP VARCHAR(16),  TM_DATABASE VARCHAR(8),  TP_MON_NAME VARCHAR(19),  TPNAME VARCHAR(64),  TRUST_ALLCLNTSF INTEGER,  TRUST_CLNTAUTH INTEGER,  UDF_MEM_SZ INTEGER,  NODETYPE INTEGER,  RELEASE INTEGER,  PLUGIN_MODE INTEGER,  GROUP_PLUGIN VARCHAR(32),  CLNT_PW_PLUGIN VARCHAR(32),  CLNT_KRB_PLUGIN VARCHAR(32),  SRVCON_PW_PLUGIN VARCHAR(32),  SRVCON_GSSPLUGIN_LIST VARCHAR(255),  SRVCON_AUTH INTEGER,  LOCAL_GSSPLUGIN VARCHAR(32))
	SPECIFIC "SYSFUN"."GET_DBM_CONFIG"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!get_dbm_config"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSFUN"."INSERT" (BLOB(1048576), 
		INTEGER, 
		INTEGER, 
		BLOB(1048576))
	RETURNS BLOB(1048576)
	SPECIFIC "SYSFUN"."INSERT2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfINSERT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."INSERT" (CLOB(1048576), 
		INTEGER, 
		INTEGER, 
		CLOB(1048576))
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."INSERT2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfINSERT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."INSERT" (VARCHAR(4000), 
		INTEGER, 
		INTEGER, 
		VARCHAR(4000))
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."INSERT1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfINSERT1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."JULIAN_DAY" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."JULIAN_DAY1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfJULIAN_DAY1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."JULIAN_DAY" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."JULIAN_DAY2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfJULIAN_DAY2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."JULIAN_DAY" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."JULIAN_DAY3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfJULIAN_DAY2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LCASE" (CLOB(1048576))
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."LCASE2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLCASE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LCASE" (VARCHAR(4000))
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."LCASE1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLCASE1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LEFT" (BLOB(1048576), 
		INTEGER)
	RETURNS BLOB(1048576)
	SPECIFIC "SYSFUN"."LEFT2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLEFT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LEFT" (CLOB(1048576), 
		INTEGER)
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."LEFT2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLEFT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LEFT" (VARCHAR(4000), 
		INTEGER)
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."LEFT1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLEFT1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."LN"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOG"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (BLOB(1048576), 
		BLOB(1048576))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE5"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (BLOB(1048576), 
		BLOB(1048576), 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (CLOB(1048576), 
		CLOB(1048576))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (CLOB(1048576), 
		CLOB(1048576), 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (VARCHAR(4000), 
		VARCHAR(4000))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOCATE" (VARCHAR(4000), 
		VARCHAR(4000), 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."LOCATE1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOCATE1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOG" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."LOG"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOG"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LOG10" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."LOG10"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLOG10"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LTRIM" (CLOB(1048576))
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."LTRIM2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLTRIM2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."LTRIM" (VARCHAR(4000))
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."LTRIM1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfLTRIM1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MIDNIGHT_SECONDS" (TIME)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."MIDNIGHT_SECONDS1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMIDNIGHT_SECONDS1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MIDNIGHT_SECONDS" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."MIDNIGHT_SECONDS2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMIDNIGHT_SECONDS2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MIDNIGHT_SECONDS" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."MIDNIGHT_SECONDS3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMIDNIGHT_SECONDS2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MOD" (BIGINT, 
		BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."MOD3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMOD3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MOD" (INTEGER, 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."MOD1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMOD1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MOD" (SMALLINT, 
		SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."MOD2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMOD2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MONTHNAME" (DATE)
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."MONTHNAME1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMONTHNAME1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MONTHNAME" (TIMESTAMP)
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."MONTHNAME2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMONTHNAME2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."MONTHNAME" (VARCHAR(32))
	RETURNS VARCHAR(100)
	SPECIFIC "SYSFUN"."MONTHNAME3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfMONTHNAME2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."OLEDBDATASOURCES" (VARCHAR(128))
	RETURNS TABLE (NAME VARCHAR(128),  PROG_ID VARCHAR(128),  DESCRIPTION VARCHAR(128))
	SPECIFIC "SYSFUN"."OLEDBDATASOURCES"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledbdatasources"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBINITPROPS" (VARCHAR(128))
	RETURNS TABLE (PROPERTY_ID INTEGER,  FLAGS INTEGER,  TYPE INTEGER,  VALUE VARCHAR(128),  DESCRIPTION VARCHAR(128))
	SPECIFIC "SYSFUN"."OLEDBINITPROPS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledbinitprops"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBLISTCOLUMNS" (VARCHAR(1024), 
		VARCHAR(128))
	RETURNS TABLE (NAME VARCHAR(128),  ORDINAL INTEGER,  FLAGS INTEGER,  COLUMNSIZE INTEGER,  TYPE VARCHAR(128),  DB2TYPE VARCHAR(128),  PRECISION INTEGER,  SCALE INTEGER,  COLUMNID VARCHAR(128))
	SPECIFIC "SYSFUN"."OLEDBLISTCOLUMNS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledblistcolumns"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBLISTTABLES" (VARCHAR(1024))
	RETURNS TABLE (CATALOG VARCHAR(128),  SCHEMA VARCHAR(128),  NAME VARCHAR(128),  TYPE VARCHAR(128),  DESCRIPTION VARCHAR(128),  PROP_ID INTEGER,  CREATED VARCHAR(128),  MODIFIED VARCHAR(128))
	SPECIFIC "SYSFUN"."OLEDBLISTTABLES"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledblisttables"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBPROVIDERS" ()
	RETURNS TABLE (NAME VARCHAR(128),  PROG_ID VARCHAR(128),  DESCRIPTION VARCHAR(128))
	SPECIFIC "SYSFUN"."OLEDBPROVIDERS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledbproviders"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBSOURCES" (VARCHAR(128))
	RETURNS TABLE (NAME VARCHAR(128),  PROG_ID VARCHAR(128),  DESCRIPTION VARCHAR(128),  TYPE INTEGER,  IS_PARENT SMALLINT)
	SPECIFIC "SYSFUN"."OLEDBSOURCES"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledbsources"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."OLEDBTESTCONNECT" (VARCHAR(1024))
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."OLEDBTESTCONNECT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!oledbcheckconnectionstring"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."OLEDBTYPECONVERT" (OLEDB_TYPE INTEGER, 
		FLAGS INTEGER, 
		LENGTH INTEGER, 
		PRECISION INTEGER, 
		SCALE INTEGER)
	RETURNS VARCHAR(128)
	SPECIFIC "SYSFUN"."OLEDBTYPECONVERT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE OLE
	EXTERNAL NAME "oledbfn!converttypestodb2"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."POWER" (BIGINT, 
		BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."POWER4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfPOWER4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."POWER" (DOUBLE, 
		DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."POWER1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfPOWER1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."POWER" (DOUBLE, 
		INTEGER)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."POWER2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfPOWER2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."POWER" (INTEGER, 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."POWER3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfPOWER3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."QUARTER" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."QUARTER1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfQUARTER1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."QUARTER" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."QUARTER2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfQUARTER2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."QUARTER" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."QUARTER3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfQUARTER2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RADIANS" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."RADIANS1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRADIANS1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RAND" ()
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."RAND1"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRAND1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RAND" (INTEGER)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."RAND2"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRAND2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."REPEAT" (BLOB(1048576), 
		INTEGER)
	RETURNS BLOB(1048576)
	SPECIFIC "SYSFUN"."REPEAT2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPEAT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."REPEAT" (CLOB(1048576), 
		INTEGER)
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."REPEAT2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPEAT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."REPEAT" (VARCHAR(4000), 
		INTEGER)
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."REPEAT1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPEAT1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."REPLACE" (BLOB(1048576), 
		BLOB(1048576), 
		BLOB(1048576))
	RETURNS BLOB(1048576)
	SPECIFIC "SYSFUN"."REPLACE2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPLACE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."REPLACE" (CLOB(1048576), 
		CLOB(1048576), 
		CLOB(1048576))
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."REPLACE2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPLACE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."REPLACE" (VARCHAR(4000), 
		VARCHAR(4000), 
		VARCHAR(4000))
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."REPLACE1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfREPLACE1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RIGHT" (BLOB(1048576), 
		INTEGER)
	RETURNS BLOB(1048576)
	SPECIFIC "SYSFUN"."RIGHT2B"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRIGHT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RIGHT" (CLOB(1048576), 
		INTEGER)
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."RIGHT2C"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRIGHT2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RIGHT" (VARCHAR(4000), 
		INTEGER)
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."RIGHT1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRIGHT1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ROUND" (BIGINT, 
		INTEGER)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."ROUND5"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfROUND5"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ROUND" (DOUBLE, 
		INTEGER)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."ROUND1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfROUND1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."ROUND" (INTEGER, 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."ROUND2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfROUND2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RTRIM" (CLOB(1048576))
	RETURNS CLOB(1048576)
	SPECIFIC "SYSFUN"."RTRIM2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRTRIM2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."RTRIM" (VARCHAR(4000))
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."RTRIM1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfRTRIM1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SIGN" (BIGINT)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."SIGN4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSIGN4"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SIGN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."SIGN1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSIGN1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SIGN" (INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."SIGN2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSIGN2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SIGN" (SMALLINT)
	RETURNS SMALLINT
	SPECIFIC "SYSFUN"."SIGN3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSIGN3"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SIN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."SIN"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSIN"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SOUNDEX" (VARCHAR(4000))
	RETURNS CHAR(4)
	SPECIFIC "SYSFUN"."SOUNDEX"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSOUNDEX"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SPACE" (INTEGER)
	RETURNS VARCHAR(4000)
	SPECIFIC "SYSFUN"."SPACE"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSPACE"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."SQLCACHE_SNAPSHOT" ()
	RETURNS TABLE (NUM_EXECUTIONS INTEGER,  NUM_COMPILATIONS INTEGER,  PREP_TIME_WORST INTEGER,  PREP_TIME_BEST INTEGER,  INT_ROWS_DELETED INTEGER,  INT_ROWS_INSERTED INTEGER,  ROWS_READ INTEGER,  INT_ROWS_UPDATED INTEGER,  ROWS_WRITTEN INTEGER,  STMT_SORTS INTEGER,  TOTAL_EXEC_TIME_S INTEGER,  TOTAL_EXEC_TIME_MS INTEGER,  TOT_U_CPU_TIME_S INTEGER,  TOT_U_CPU_TIME_MS INTEGER,  TOT_S_CPU_TIME_S INTEGER,  TOT_S_CPU_TIME_MS INTEGER,  DB_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216))
	SPECIFIC "SYSFUN"."SQLCACHE_SNAPSHOT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!SQLCACHE_SNAPSHOT"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSFUN"."SQRT" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."SQRT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfSQRT"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TAN" (DOUBLE)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."TAN"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTAN"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TIMESTAMPDIFF" (INTEGER, 
		CHAR(22))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."TIMESTAMPDIFF"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTIMESTAMPDIFF"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TIMESTAMP_ISO" (DATE)
	RETURNS TIMESTAMP
	SPECIFIC "SYSFUN"."TIMESTAMP_ISO1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTIMESTAMPDATE"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TIMESTAMP_ISO" (TIME)
	RETURNS TIMESTAMP
	SPECIFIC "SYSFUN"."TIMESTAMP_ISO2"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTIMESTAMPTIME"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TIMESTAMP_ISO" (TIMESTAMP)
	RETURNS TIMESTAMP
	SPECIFIC "SYSFUN"."TIMESTAMP_ISO3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTIMESTAMP"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TIMESTAMP_ISO" (VARCHAR(32))
	RETURNS TIMESTAMP
	SPECIFIC "SYSFUN"."TIMESTAMP_ISO4"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTIMESTAMP"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNC" (BIGINT, 
		INTEGER)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."TRUNC5"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE5"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNC" (DOUBLE, 
		INTEGER)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."TRUNC1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNC" (INTEGER, 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."TRUNC2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNCATE" (BIGINT, 
		INTEGER)
	RETURNS BIGINT
	SPECIFIC "SYSFUN"."TRUNCATE5"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE5"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNCATE" (DOUBLE, 
		INTEGER)
	RETURNS DOUBLE
	SPECIFIC "SYSFUN"."TRUNCATE1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."TRUNCATE" (INTEGER, 
		INTEGER)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."TRUNCATE2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfTRUNCATE2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."UCASE" (VARCHAR(4000))
	RETURNS VARCHAR(1)
	SPECIFIC "SYSFUN"."UCASE"
	READS SQL DATA
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE 
	EXTERNAL NAME "SYSIBM.TRANSLATE (SYSIBM.VARCHAR)"
	FENCED NOT THREADSAFE
	PARAMETER STYLE;

CREATE FUNCTION "SYSFUN"."USERS_GROUPS" (UG_TYPE INTEGER, 
		UG_NAME VARCHAR(30))
	RETURNS TABLE (NAME VARCHAR(30))
	SPECIFIC "SYSFUN"."USERS_GROUPS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!accountsGroups"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSFUN"."VEBLOB_CP_LARGE" (BLOB(1000000), 
		INTEGER, 
		INTEGER, 
		INTEGER)
	RETURNS BLOB(1000000)
	SPECIFIC "SYSFUN"."VEBLOB_CP_LARGE"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfVEBLOB_CP_LARGE"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."VEBLOB_CP_SMALL" (BLOB(500000), 
		INTEGER, 
		INTEGER, 
		INTEGER)
	RETURNS BLOB(500000)
	SPECIFIC "SYSFUN"."VEBLOB_CP_SMALL"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfVEBLOB_CP_SMALL"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK_ISO" (DATE)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK_ISO1"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK_ISO1"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK_ISO" (TIMESTAMP)
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK_ISO2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK_ISO2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSFUN"."WEEK_ISO" (VARCHAR(32))
	RETURNS INTEGER
	SPECIFIC "SYSFUN"."WEEK_ISO3"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2clifn!CLI_udfWEEK_ISO2"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_CONTACTGROUPS" ()
	RETURNS TABLE (NAME VARCHAR(128),  DESCRIPTION VARCHAR(128),  MEMBERNAME VARCHAR(128),  MEMBERTYPE VARCHAR(7))
	SPECIFIC "SYSPROC"."ADMIN_GET_CONTACTGROUPS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_contactgroups"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1024;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_CONTACTS" ()
	RETURNS TABLE (NAME VARCHAR(128),  TYPE VARCHAR(5),  ADDRESS VARCHAR(128),  MAX_PAGE_LENGTH INTEGER,  DESCRIPTION VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_GET_CONTACTS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_contacts"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1024;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE" ()
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  MAX_PARTITION_MEM BIGINT,  CURRENT_PARTITION_MEM BIGINT,  PEAK_PARTITION_MEM BIGINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE_AP"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!adminGetDbpMemUsage_ap"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE" (INTEGER)
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  MAX_PARTITION_MEM BIGINT,  CURRENT_PARTITION_MEM BIGINT,  PEAK_PARTITION_MEM BIGINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!adminGetDbpMemUsage"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_INDEX_COMPRESS_INFO" (OBJECTTYPE VARCHAR(1), 
		OBJECTSCHEMA VARCHAR(128), 
		OBJECTNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER, 
		DATAPARTITIONID INTEGER)
	RETURNS TABLE (INDSCHEMA VARCHAR(128),  INDNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  IID SMALLINT,  DATAPARTITIONID INTEGER,  COMPRESS_ATTR CHAR(1),  INDEX_COMPRESSED CHAR(1),  PCT_PAGES_SAVED SMALLINT,  NUM_LEAF_PAGES_SAVED BIGINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_INDEX_COMPRESS_INFO"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!admin_get_index_compress_info"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_INDEX_INFO" (OBJECTTYPE VARCHAR(1), 
		OBJECTSCHEMA VARCHAR(128), 
		OBJECTNAME VARCHAR(128))
	RETURNS TABLE (INDSCHEMA VARCHAR(128),  INDNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  IID SMALLINT,  DATAPARTITIONID INTEGER,  COMPRESS_ATTR CHAR(1),  INDEX_COMPRESSED CHAR(1),  INDEX_PARTITIONING CHAR(1),  INDEX_OBJECT_L_SIZE BIGINT,  INDEX_OBJECT_P_SIZE BIGINT,  INDEX_REQUIRES_REBUILD CHAR(1),  LARGE_RIDS CHAR(1))
	SPECIFIC "SYSPROC"."ADMIN_GET_INDEX_INFO"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!admin_get_index_info"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_MSGS" (OPERATION_ID VARCHAR(139))
	RETURNS TABLE (DBPARTITIONNUM INTEGER,  AGENTTYPE CHAR(4),  SQLCODE VARCHAR(9),  MSG VARCHAR(1024))
	SPECIFIC "SYSPROC"."ADMIN_GET_MSGS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2admcmd!admin_get_msgs"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		EXECMODE VARCHAR(30))
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  COMPRESS_ATTR CHAR(1),  DICT_BUILDER VARCHAR(30),  DICT_BUILD_TIMESTAMP TIMESTAMP,  COMPRESS_DICT_SIZE BIGINT,  EXPAND_DICT_SIZE BIGINT,  ROWS_SAMPLED INTEGER,  PAGES_SAVED_PERCENT SMALLINT,  BYTES_SAVED_PERCENT SMALLINT,  AVG_COMPRESS_REC_LENGTH SMALLINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_tab_compress_info"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO_V97" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		EXECMODE VARCHAR(30))
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  COMPRESS_ATTR CHAR(1),  DICT_BUILDER VARCHAR(30),  DICT_BUILD_TIMESTAMP TIMESTAMP,  COMPRESS_DICT_SIZE BIGINT,  EXPAND_DICT_SIZE BIGINT,  ROWS_SAMPLED INTEGER,  PAGES_SAVED_PERCENT SMALLINT,  BYTES_SAVED_PERCENT SMALLINT,  AVG_COMPRESS_REC_LENGTH SMALLINT,  OBJECT_TYPE VARCHAR(4))
	SPECIFIC "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO_V97"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_tab_compress_info_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128))
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TABTYPE CHAR(1),  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  AVAILABLE CHAR(1),  DATA_OBJECT_L_SIZE BIGINT,  DATA_OBJECT_P_SIZE BIGINT,  INDEX_OBJECT_L_SIZE BIGINT,  INDEX_OBJECT_P_SIZE BIGINT,  LONG_OBJECT_L_SIZE BIGINT,  LONG_OBJECT_P_SIZE BIGINT,  LOB_OBJECT_L_SIZE BIGINT,  LOB_OBJECT_P_SIZE BIGINT,  XML_OBJECT_L_SIZE BIGINT,  XML_OBJECT_P_SIZE BIGINT,  INDEX_TYPE SMALLINT,  REORG_PENDING CHAR(1),  INPLACE_REORG_STATUS VARCHAR(10),  LOAD_STATUS VARCHAR(12),  READ_ACCESS_ONLY CHAR(1),  NO_LOAD_RESTART CHAR(1),  NUM_REORG_REC_ALTERS SMALLINT,  INDEXES_REQUIRE_REBUILD CHAR(1),  LARGE_RIDS CHAR(1),  LARGE_SLOTS CHAR(1),  DICTIONARY_SIZE BIGINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_TAB_INFO"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_tab_info"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO_V95" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128))
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TABTYPE CHAR(1),  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  AVAILABLE CHAR(1),  DATA_OBJECT_L_SIZE BIGINT,  DATA_OBJECT_P_SIZE BIGINT,  INDEX_OBJECT_L_SIZE BIGINT,  INDEX_OBJECT_P_SIZE BIGINT,  LONG_OBJECT_L_SIZE BIGINT,  LONG_OBJECT_P_SIZE BIGINT,  LOB_OBJECT_L_SIZE BIGINT,  LOB_OBJECT_P_SIZE BIGINT,  XML_OBJECT_L_SIZE BIGINT,  XML_OBJECT_P_SIZE BIGINT,  INDEX_TYPE SMALLINT,  REORG_PENDING CHAR(1),  INPLACE_REORG_STATUS VARCHAR(10),  LOAD_STATUS VARCHAR(12),  READ_ACCESS_ONLY CHAR(1),  NO_LOAD_RESTART CHAR(1),  NUM_REORG_REC_ALTERS SMALLINT,  INDEXES_REQUIRE_REBUILD CHAR(1),  LARGE_RIDS CHAR(1),  LARGE_SLOTS CHAR(1),  DICTIONARY_SIZE BIGINT,  BLOCKS_PENDING_CLEANUP BIGINT,  STATSTYPE CHAR(1))
	SPECIFIC "SYSPROC"."ADMIN_GET_TAB_INFO_V95"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_tab_info_v95"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO_V97" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128))
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TABTYPE CHAR(1),  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  AVAILABLE CHAR(1),  DATA_OBJECT_L_SIZE BIGINT,  DATA_OBJECT_P_SIZE BIGINT,  INDEX_OBJECT_L_SIZE BIGINT,  INDEX_OBJECT_P_SIZE BIGINT,  LONG_OBJECT_L_SIZE BIGINT,  LONG_OBJECT_P_SIZE BIGINT,  LOB_OBJECT_L_SIZE BIGINT,  LOB_OBJECT_P_SIZE BIGINT,  XML_OBJECT_L_SIZE BIGINT,  XML_OBJECT_P_SIZE BIGINT,  INDEX_TYPE SMALLINT,  REORG_PENDING CHAR(1),  INPLACE_REORG_STATUS VARCHAR(10),  LOAD_STATUS VARCHAR(12),  READ_ACCESS_ONLY CHAR(1),  NO_LOAD_RESTART CHAR(1),  NUM_REORG_REC_ALTERS SMALLINT,  INDEXES_REQUIRE_REBUILD CHAR(1),  LARGE_RIDS CHAR(1),  LARGE_SLOTS CHAR(1),  DICTIONARY_SIZE BIGINT,  BLOCKS_PENDING_CLEANUP BIGINT,  STATSTYPE CHAR(1),  XML_RECORD_TYPE SMALLINT,  RECLAIMABLE_SPACE BIGINT,  XML_DICTIONARY_SIZE BIGINT)
	SPECIFIC "SYSPROC"."ADMIN_GET_TAB_INFO_V97"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_get_tab_info_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TEMP_COLUMNS" (APPLICATION_HANDLE BIGINT, 
		TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128))
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  APPLICATION_NAME VARCHAR(256),  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  COLNAME VARCHAR(128),  COLNO SMALLINT,  TYPESCHEMA VARCHAR(128),  TYPENAME VARCHAR(128),  LENGTH INTEGER,  SCALE SMALLINT,  DEFAULT VARCHAR(254),  NULLS CHAR(1),  CODEPAGE SMALLINT,  LOGGED CHAR(1),  COMPACT CHAR(1),  INLINE_LENGTH INTEGER,  IDENTITY CHAR(1),  GENERATED CHAR(1))
	SPECIFIC "SYSPROC"."ADMIN_GET_TEMP_COLUMNS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!admin_get_temp_columns"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_GET_TEMP_TABLES" (APPLICATION_HANDLE BIGINT, 
		TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128))
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  APPLICATION_NAME VARCHAR(256),  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  INSTANTIATOR VARCHAR(128),  INSTANTIATORTYPE CHAR(1),  TEMPTABTYPE CHAR(1),  INSTANTIATION_TIME TIMESTAMP,  COLCOUNT SMALLINT,  TAB_FILE_ID BIGINT,  TBSP_ID BIGINT,  PMAP_ID SMALLINT,  PARTITION_MODE CHAR(1),  CODEPAGE SMALLINT,  ONCOMMIT CHAR(1),  ONROLLBACK CHAR(1),  LOGGED CHAR(1))
	SPECIFIC "SYSPROC"."ADMIN_GET_TEMP_TABLES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!admin_get_temp_tables"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ADMIN_LIST_DB_PATHS" ()
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  TYPE VARCHAR(64),  PATH VARCHAR(5000))
	SPECIFIC "SYSPROC"."ADMIN_LIST_DB_PATHS"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!admin_list_db_paths"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 10000;

CREATE FUNCTION "SYSPROC"."ADMIN_LIST_HIST" ()
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  EID BIGINT,  START_TIME VARCHAR(14),  SEQNUM SMALLINT,  END_TIME VARCHAR(14),  FIRSTLOG VARCHAR(254),  LASTLOG VARCHAR(254),  BACKUP_ID VARCHAR(24),  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  COMMENT VARCHAR(254),  CMD_TEXT CLOB(2097152),  NUM_TBSPS INTEGER,  TBSPNAMES CLOB(5242880),  OPERATION CHAR(1),  OPERATIONTYPE CHAR(1),  OBJECTTYPE CHAR(1),  LOCATION VARCHAR(255),  DEVICETYPE CHAR(1),  ENTRY_STATUS CHAR(1),  SQLCAID VARCHAR(8),  SQLCABC INTEGER,  SQLCODE INTEGER,  SQLERRML SMALLINT,  SQLERRMC VARCHAR(70),  SQLERRP VARCHAR(8),  SQLERRD1 INTEGER,  SQLERRD2 INTEGER,  SQLERRD3 INTEGER,  SQLERRD4 INTEGER,  SQLERRD5 INTEGER,  SQLERRD6 INTEGER,  SQLWARN VARCHAR(11),  SQLSTATE VARCHAR(5))
	SPECIFIC "SYSPROC"."ADMIN_LIST_HIST"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2adminListHist!adminListHist"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1000;

CREATE FUNCTION "SYSPROC"."AM_BASE_RPTS" (ID INTEGER, 
		TYPE CHAR(4), 
		CLIENT_LOCALE VARCHAR(33))
	RETURNS TABLE (ID INTEGER,  TYPE CHAR(4),  NAME VARCHAR(256),  DESCRIPTION VARCHAR(16384),  SWITCHES VARCHAR(100))
	SPECIFIC "SYSPROC"."AM_BASE_RPTS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2am!am_base_rpts"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."AM_BASE_RPT_RECOMS" (REPORT_ID INTEGER, 
		CLIENT_LOCALE VARCHAR(33))
	RETURNS TABLE (REPORT_ID INTEGER,  RECOM_NAME VARCHAR(256),  RECOM_DESCRIPTION CLOB(32768))
	SPECIFIC "SYSPROC"."AM_BASE_RPT_RECOMS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2am!am_base_rpt_recoms"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."AUDIT_ARCHIVE" (VARCHAR(1024), 
		INTEGER)
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  PATH VARCHAR(1024),  FILE VARCHAR(1024),  SQLCODE INTEGER,  SQLSTATE VARCHAR(5),  SQLERRMC VARCHAR (70) FOR BIT DATA)
	SPECIFIC "SYSPROC"."AUDIT_ARCHIVE_TF"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!auditArchive"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."AUDIT_LIST_LOGS" (VARCHAR(1024))
	RETURNS TABLE (PATH VARCHAR(1024),  FILE VARCHAR(1024),  SIZE BIGINT)
	SPECIFIC "SYSPROC"."AUDIT_LIST_LOGS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!auditListLogs"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."AUTH_GET_INSTANCE_AUTHID" ()
	RETURNS VARCHAR(128)
	SPECIFIC "SYSPROC"."AUTH_GET_INSTANCE_AUTHID"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!getInstanceAuthId"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."AUTH_LIST_AUTHORITIES_FOR_AUTHID" (AUTHID VARCHAR(128), 
		AUTHIDTYPE VARCHAR(1))
	RETURNS TABLE (AUTHORITY VARCHAR(128),  D_USER CHAR(1),  D_GROUP CHAR(1),  D_PUBLIC CHAR(1),  ROLE_USER CHAR(1),  ROLE_GROUP CHAR(1),  ROLE_PUBLIC CHAR(1),  D_ROLE CHAR(1))
	SPECIFIC "SYSPROC"."AUTH_LIST_AUTHORITIES_FOR_AUTHID"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!getAuthorities"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."AUTH_LIST_GROUPS_FOR_AUTHID" (AUTHID VARCHAR(128))
	RETURNS TABLE (GROUP VARCHAR(128))
	SPECIFIC "SYSPROC"."AUTH_LIST_GROUPS_FOR_AUTHID"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!getGroups"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."COMPILATION_ENV" (COMP_ENV BLOB(2097152))
	RETURNS TABLE (NAME VARCHAR(256),  VALUE VARCHAR(1024))
	SPECIFIC "SYSPROC"."COMPILATION_ENV"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!compilationEnvUdf"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."DBM_GET_CFG" ()
	RETURNS TABLE (NAME VARCHAR(32),  VALUE VARCHAR(256),  VALUE_FLAGS VARCHAR(10),  DEFERRED_VALUE VARCHAR(256),  DEFERRED_VALUE_FLAGS VARCHAR(10),  DATATYPE VARCHAR(128))
	SPECIFIC "SYSPROC"."DBM_GET_CFG"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!dbm_get_cfg"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."DB_GET_CFG" ()
	RETURNS TABLE (NAME VARCHAR(32),  VALUE VARCHAR(1024),  VALUE_FLAGS VARCHAR(10),  DEFERRED_VALUE VARCHAR(1024),  DEFERRED_VALUE_FLAGS VARCHAR(10),  DATATYPE VARCHAR(128),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."DB_GET_CFG"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!db_get_cfg"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."DB_PARTITIONS" ()
	RETURNS TABLE (PARTITION_NUMBER SMALLINT,  HOST_NAME VARCHAR(256),  PORT_NUMBER SMALLINT,  SWITCH_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."DB_PARTITIONS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!db_partitions"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_DB2_SYSTEM_RESOURCES" (MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  DB2_PROCESS_NAME VARCHAR(128),  DB2_PROCESS_ID BIGINT,  CPU_USER BIGINT,  CPU_SYSTEM BIGINT)
	SPECIFIC "SYSPROC"."ENV_GET_DB2_SYSTEM_RESOURCES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!envGetDB2SystemResources"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ENV_GET_FEATURE_INFO" ()
	RETURNS TABLE (FEATURE_NAME VARCHAR(26),  FEATURE_FULLNAME VARCHAR(100),  LICENSE_INSTALLED CHAR(1),  PRODUCT_NAME VARCHAR(26),  FEATURE_USE_STATUS VARCHAR(30))
	SPECIFIC "SYSPROC"."ENV_GET_FEATURE_INFO"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2envinfo!ENV_GET_FEATURE_INFO"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_INST_INFO" ()
	RETURNS TABLE (INST_NAME VARCHAR(128),  IS_INST_PARTITIONABLE SMALLINT,  NUM_DBPARTITIONS INTEGER,  INST_PTR_SIZE INTEGER,  RELEASE_NUM VARCHAR(128),  SERVICE_LEVEL VARCHAR(128),  BLD_LEVEL VARCHAR(128),  PTF VARCHAR(128),  FIXPACK_NUM INTEGER)
	SPECIFIC "SYSPROC"."ENV_GET_INST_INFO"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2envinfo!ENV_GET_INST_INFO"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_NETWORK_RESOURCES" ()
	RETURNS TABLE (MEMBER SMALLINT,  HOST_NAME VARCHAR(255),  ADAPTER_NAME VARCHAR(255),  PACKETS_RECEIVED BIGINT,  PACKETS_SENT BIGINT,  PACKET_RECEIVE_ERRORS BIGINT,  PACKET_SEND_ERRORS BIGINT,  TOTAL_BYTES_RECEIVED BIGINT,  TOTAL_BYTES_SENT BIGINT)
	SPECIFIC "SYSPROC"."ENV_GET_NETWORK_RESOURCES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!envGetNetworkResources"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ENV_GET_PROD_INFO" ()
	RETURNS TABLE (INSTALLED_PROD VARCHAR(26),  IS_LICENSED SMALLINT,  PROD_RELEASE VARCHAR(26))
	SPECIFIC "SYSPROC"."ENV_GET_PROD_INFO"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2envinfo!ENV_GET_PROD_INFO"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_PROD_INFO_V95" ()
	RETURNS TABLE (INSTALLED_PROD VARCHAR(26),  INSTALLED_PROD_FULLNAME VARCHAR(100),  LICENSE_INSTALLED CHAR(1),  PROD_RELEASE VARCHAR(26),  LICENSE_TYPE VARCHAR(50))
	SPECIFIC "SYSPROC"."ENV_GET_PROD_INFO_V95"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2envinfo!ENV_GET_PROD_INFO_V95"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_SYSTEM_RESOURCES" ()
	RETURNS TABLE (MEMBER SMALLINT,  OS_NAME VARCHAR(256),  HOST_NAME VARCHAR(255),  OS_VERSION VARCHAR(256),  OS_RELEASE VARCHAR(256),  MACHINE_IDENTIFICATION VARCHAR(256),  OS_LEVEL VARCHAR(256),  CPU_TOTAL BIGINT,  CPU_ONLINE BIGINT,  CPU_CONFIGURED BIGINT,  CPU_SPEED BIGINT,  CPU_TIMEBASE BIGINT,  CPU_HMT_DEGREE BIGINT,  CPU_CORES_PER_SOCKET BIGINT,  MEMORY_TOTAL BIGINT,  MEMORY_FREE BIGINT,  MEMORY_SWAP_TOTAL BIGINT,  MEMORY_SWAP_FREE BIGINT,  VIRTUAL_MEM_TOTAL BIGINT,  VIRTUAL_MEM_RESERVED BIGINT,  VIRTUAL_MEM_FREE BIGINT,  CPU_LOAD_SHORT DOUBLE,  CPU_LOAD_MEDIUM DOUBLE,  CPU_LOAD_LONG DOUBLE,  CPU_USAGE_TOTAL SMALLINT,  CPU_USER BIGINT,  CPU_IDLE BIGINT,  CPU_IOWAIT BIGINT,  CPU_SYSTEM BIGINT,  SWAP_PAGE_SIZE BIGINT,  SWAP_PAGES_IN BIGINT,  SWAP_PAGES_OUT BIGINT)
	SPECIFIC "SYSPROC"."ENV_GET_SYSTEM_RESOURCES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!envGetSystemResources"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."ENV_GET_SYS_INFO" ()
	RETURNS TABLE (OS_NAME VARCHAR(256),  OS_VERSION VARCHAR(256),  OS_RELEASE VARCHAR(256),  HOST_NAME VARCHAR(256),  TOTAL_CPUS INTEGER,  CONFIGURED_CPUS INTEGER,  TOTAL_MEMORY INTEGER)
	SPECIFIC "SYSPROC"."ENV_GET_SYS_INFO"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2envinfo!ENV_GET_SYS_INFO"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."ENV_GET_SYS_RESOURCES" ()
	RETURNS TABLE (NAME VARCHAR(128),  VALUE VARCHAR(1024),  DATATYPE VARCHAR(128),  UNIT VARCHAR(128),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."ENV_GET_SYS_RESOURCES"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!env_get_sys_resources"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 256;

CREATE FUNCTION "SYSPROC"."EVMON_FORMAT_UE_TO_STREAM" (OPTIONS VARCHAR(1028), 
		PARTITION_KEY INTEGER, 
		APPL_ID VARCHAR(128), 
		APPL_NAME VARCHAR(255), 
		EVENT_CORRELATION_ID VARCHAR (32) FOR BIT DATA, 
		EVENT_DATA BLOB(5242880), 
		EVENT_ID BIGINT, 
		EVENT_TIMESTAMP TIMESTAMP, 
		EVENT_TYPE VARCHAR(128), 
		MEMBER INTEGER, 
		RECORD_SEQ_NUM BIGINT, 
		RECORD_TYPE BIGINT, 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		WORKLOAD_NAME VARCHAR(128))
	RETURNS TABLE (XMLID VARCHAR(1024),  XMLREPORT BLOB(104857600))
	SPECIFIC "SYSPROC"."EVMON_FORMAT_UE_TO_STREAM"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monEvmonUEToStream"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."EVMON_FORMAT_UE_TO_XML" (OPTIONS VARCHAR(1028), 
		PARTITION_KEY INTEGER, 
		APPL_ID VARCHAR(128), 
		APPL_NAME VARCHAR(255), 
		EVENT_CORRELATION_ID VARCHAR (32) FOR BIT DATA, 
		EVENT_DATA BLOB(5242880), 
		EVENT_ID BIGINT, 
		EVENT_TIMESTAMP TIMESTAMP, 
		EVENT_TYPE VARCHAR(128), 
		MEMBER INTEGER, 
		RECORD_SEQ_NUM BIGINT, 
		RECORD_TYPE BIGINT, 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		WORKLOAD_NAME VARCHAR(128))
	RETURNS TABLE (XMLID VARCHAR(1024),  XMLREPORT BLOB(104857600))
	SPECIFIC "SYSPROC"."EVMON_FORMAT_UE_TO_XML"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monEvmonUEToXML"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."EXDYN_DGTT_COLUMN" (POOL INTEGER, 
		OBJECT INTEGER)
	RETURNS TABLE (COLNO INTEGER,  NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."EXDYN_DGTT_COLUMN"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2exdyn!dgtt_column"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 50;

CREATE FUNCTION "SYSPROC"."EXDYN_DGTT_IDXCOL" (POOL INTEGER, 
		OBJECT INTEGER, 
		INDEX INTEGER)
	RETURNS TABLE (COLSEQ INTEGER,  NAME VARCHAR(128),  ORDER CHAR(1))
	SPECIFIC "SYSPROC"."EXDYN_DGTT_IDXCOL"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2exdyn!dgtt_idxcol"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 50;

CREATE FUNCTION "SYSPROC"."EXDYN_DGTT_INDEX" (POOL INTEGER, 
		OBJECT INTEGER, 
		INDEX INTEGER)
	RETURNS TABLE (SCHEMA VARCHAR(128),  NAME VARCHAR(128),  TYPE CHAR(4),  INTERNAL_FORMAT SMALLINT)
	SPECIFIC "SYSPROC"."EXDYN_DGTT_INDEX"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2exdyn!dgtt_index"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 50;

CREATE FUNCTION "SYSPROC"."EXDYN_DGTT_TABLE" (POOL INTEGER, 
		OBJECT INTEGER)
	RETURNS TABLE (SCHEMA VARCHAR(128),  NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."EXDYN_DGTT_TABLE"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2exdyn!dgtt_table"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 50;

CREATE FUNCTION "SYSPROC"."EXPLAIN_FORMAT_STATS" (SNAPSHOT BLOB(10485760))
	RETURNS CLOB(52428800)
	SPECIFIC "SYSPROC"."EXPLAIN_FORMAT_STATS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!sqlSnapshotStatsFormat"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."EXPLAIN_GET_MSG" (VARCHAR(33), 
		INTEGER, 
		VARCHAR(1000), 
		VARCHAR(1000), 
		VARCHAR(1000))
	RETURNS TABLE (LOCALE VARCHAR(33),  MSG VARCHAR(4096))
	SPECIFIC "SYSPROC"."EXPLAIN_GET_MSG"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2msg!sqlGetExplainDiagMessage"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1;

CREATE FUNCTION "SYSPROC"."EXPLAIN_GET_MSG2" (VARCHAR(33), 
		INTEGER, 
		VARCHAR(1000), 
		VARCHAR(1000), 
		VARCHAR(1000))
	RETURNS TABLE (LOCALE VARCHAR(33),  MSG VARCHAR(4096))
	SPECIFIC "SYSPROC"."EXPLAIN_GET_MSG2"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2msg!sqlGetExplainDiagMessage2"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1;

CREATE FUNCTION "SYSPROC"."GET_ROUTINE_OPTS" ()
	RETURNS VARCHAR(1024)
	SPECIFIC "SYSPROC"."GET_ROUTINE_OPTS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2pvm!get_options"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL;

CREATE FUNCTION "SYSPROC"."HEALTH_CONT_HI" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONTAINER_NAME VARCHAR(256),  NODE_NUMBER INTEGER,  HI_ID BIGINT,  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_CONT_HI"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_cont_hi"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_CONT_HI_HIS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONTAINER_NAME VARCHAR(256),  NODE_NUMBER INTEGER,  HI_ID BIGINT,  HI_TIMESTAMP TIMESTAMP,  HI_VALUE SMALLINT,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_CONT_HI_HIS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_cont_hi_his"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_CONT_INFO" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONTAINER_NAME VARCHAR(256),  TABLESPACE_NAME VARCHAR(128),  NODE_NUMBER INTEGER,  ROLLED_UP_ALERT_STATE BIGINT,  ROLLED_UP_ALERT_STATE_DETAIL VARCHAR(20))
	SPECIFIC "SYSPROC"."HEALTH_CONT_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_cont_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DBM_HI" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  SERVER_INSTANCE_NAME VARCHAR(128),  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_DBM_HI"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_dbm_hi"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DBM_HI_HIS" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  SERVER_INSTANCE_NAME VARCHAR(128),  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_DBM_HI_HIS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_dbm_hi_his"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DBM_INFO" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SERVER_INSTANCE_NAME VARCHAR(128),  ROLLED_UP_ALERT_STATE BIGINT,  ROLLED_UP_ALERT_STATE_DETAIL VARCHAR(20),  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  NUM_NODES_IN_DB2_INSTANCE INTEGER)
	SPECIFIC "SYSPROC"."HEALTH_DBM_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_dbm_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DB_HI" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  DB_NAME VARCHAR(128),  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_DB_HI"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_db_hi"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DB_HIC" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  DB_NAME VARCHAR(128),  HI_OBJ_NAME VARCHAR(512),  HI_OBJ_DETAIL VARCHAR(512),  HI_OBJ_STATE SMALLINT,  HI_OBJ_STATE_DETAIL VARCHAR(20),  HI_TIMESTAMP TIMESTAMP)
	SPECIFIC "SYSPROC"."HEALTH_DB_HIC"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_db_hic"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DB_HIC_HIS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (HI_HIS_ENTRY_NUM SMALLINT,  SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  DB_NAME VARCHAR(128),  HI_OBJ_NAME VARCHAR(512),  HI_OBJ_STATE SMALLINT,  HI_OBJ_STATE_DETAIL VARCHAR(20),  HI_TIMESTAMP TIMESTAMP)
	SPECIFIC "SYSPROC"."HEALTH_DB_HIC_HIS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_db_hic_his"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DB_HI_HIS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  HI_ID BIGINT,  DB_NAME VARCHAR(128),  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_DB_HI_HIS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_db_hi_his"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_DB_INFO" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  DB_PATH VARCHAR(1024),  DB_LOCATION INTEGER,  SERVER_PLATFORM INTEGER,  ROLLED_UP_ALERT_STATE BIGINT,  ROLLED_UP_ALERT_STATE_DETAIL VARCHAR(20))
	SPECIFIC "SYSPROC"."HEALTH_DB_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_db_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_GET_ALERT_ACTION_CFG" (OBJECTTYPE VARCHAR(3), 
		CFG_LEVEL VARCHAR(1), 
		DBNAME VARCHAR(128), 
		OBJECTNAME VARCHAR(1024))
	RETURNS TABLE (OBJECTTYPE VARCHAR(3),  CFG_LEVEL CHAR(1),  DBNAME VARCHAR(128),  OBJECTNAME VARCHAR(512),  ID BIGINT,  IS_DEFAULT SMALLINT,  CONDITION VARCHAR(32),  ACTIONTYPE CHAR(1),  ACTIONNAME VARCHAR(5000),  USERID VARCHAR(1024),  HOSTNAME VARCHAR(255),  SCRIPT_TYPE CHAR(1),  WORKING_DIR VARCHAR(5000),  TERMINATION_CHAR VARCHAR(4),  PARAMETERS VARCHAR(200))
	SPECIFIC "SYSPROC"."HEALTH_GET_ALERT_ACTION_CFG"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!health_get_alert_action_cfg"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."HEALTH_GET_ALERT_CFG" (OBJECTTYPE VARCHAR(3), 
		CFG_LEVEL VARCHAR(1), 
		DBNAME VARCHAR(128), 
		OBJECTNAME VARCHAR(1024))
	RETURNS TABLE (OBJECTTYPE VARCHAR(3),  CFG_LEVEL CHAR(1),  DBNAME VARCHAR(128),  OBJECTNAME VARCHAR(512),  ID BIGINT,  IS_DEFAULT SMALLINT,  WARNING_THRESHOLD BIGINT,  ALARM_THRESHOLD BIGINT,  SENSITIVITY BIGINT,  EVALUATE SMALLINT,  ACTION_ENABLED SMALLINT)
	SPECIFIC "SYSPROC"."HEALTH_GET_ALERT_CFG"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!health_get_alert_cfg"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."HEALTH_GET_IND_DEFINITION" (LOCALE VARCHAR(33))
	RETURNS TABLE (ID BIGINT,  NAME VARCHAR(128),  SHORT_DESCRIPTION VARCHAR(1024),  LONG_DESCRIPTION VARCHAR(32672),  TYPE VARCHAR(16),  UNIT VARCHAR(1024),  CATEGORY VARCHAR(1024),  FORMULA VARCHAR(512),  REFRESH_INTERVAL BIGINT)
	SPECIFIC "SYSPROC"."HEALTH_GET_IND_DEFINITION"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!health_get_ind_definition"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."HEALTH_GET_NOTIFICATION_LIST" ()
	RETURNS TABLE (NAME VARCHAR(128),  TYPE VARCHAR(7))
	SPECIFIC "SYSPROC"."HEALTH_GET_NOTIFICATION_LIST"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!health_get_notification_list"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1024;

CREATE FUNCTION "SYSPROC"."HEALTH_TBS_HI" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_NAME VARCHAR(128),  HI_ID BIGINT,  HI_VALUE SMALLINT,  HI_TIMESTAMP TIMESTAMP,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_TBS_HI"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_tbs_hi"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_TBS_HI_HIS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_NAME VARCHAR(128),  HI_ID BIGINT,  HI_TIMESTAMP TIMESTAMP,  HI_VALUE SMALLINT,  HI_ALERT_STATE BIGINT,  HI_ALERT_STATE_DETAIL VARCHAR(20),  HI_FORMULA VARCHAR(2048),  HI_ADDITIONAL_INFO VARCHAR(4096))
	SPECIFIC "SYSPROC"."HEALTH_TBS_HI_HIS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_tbs_hi_his"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."HEALTH_TBS_INFO" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_NAME VARCHAR(128),  ROLLED_UP_ALERT_STATE BIGINT,  ROLLED_UP_ALERT_STATE_DETAIL VARCHAR(20))
	SPECIFIC "SYSPROC"."HEALTH_TBS_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!health_tbs_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."MON_FORMAT_LOCK_NAME" (LOCK_NAME VARCHAR(32))
	RETURNS TABLE (NAME VARCHAR(256),  VALUE VARCHAR(1024))
	SPECIFIC "SYSPROC"."MON_FORMAT_LOCK_NAME"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monFormatLockName"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW" (XMLDOC BLOB(104857600))
	RETURNS TABLE (METRIC_NAME VARCHAR(128),  PROC_METRIC_NAME VARCHAR(128),  TOTAL_TIME_VALUE BIGINT,  PROC_TIME_VALUE BIGINT,  COUNT BIGINT,  PARENT_METRIC_NAME VARCHAR(128),  PARENT_PROC_METRIC_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monFormatXMLComponentTimesByRow"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_FORMAT_XML_METRICS_BY_ROW" (XMLDOC BLOB(104857600))
	RETURNS TABLE (METRIC_NAME VARCHAR(128),  VALUE BIGINT)
	SPECIFIC "SYSPROC"."MON_FORMAT_XML_METRICS_BY_ROW"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monFormatXMLMetricsByRow"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_FORMAT_XML_WAIT_TIMES_BY_ROW" (XMLDOC BLOB(104857600))
	RETURNS TABLE (METRIC_NAME VARCHAR(128),  TOTAL_TIME_VALUE BIGINT,  COUNT BIGINT,  PARENT_METRIC_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."MON_FORMAT_XML_WAIT_TIMES_BY_ROW"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monFormatXMLWaitTimesByRow"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_ACTIVITY_DETAILS" (APPLICATION_HANDLE BIGINT, 
		UOW_ID INTEGER, 
		ACTIVITY_ID INTEGER, 
		MEMBER INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  UOW_ID INTEGER,  ACTIVITY_ID INTEGER,  MEMBER SMALLINT,  DETAILS BLOB(8388608))
	SPECIFIC "SYSPROC"."MON_GET_ACTIVITY_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!monGetActivityDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_APPLICATION_HANDLE" ()
	RETURNS BIGINT
	SPECIFIC "SYSPROC"."MON_GET_APPLICATION_HANDLE"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!mon_get_application_handle"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."MON_GET_APPLICATION_ID" ()
	RETURNS VARCHAR(128)
	SPECIFIC "SYSPROC"."MON_GET_APPLICATION_ID"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!mon_get_application_id"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."MON_GET_APPL_LOCKWAIT" (APPLICATION_HANDLE BIGINT, 
		MEMBER INTEGER)
	RETURNS TABLE (LOCK_WAIT_START_TIME TIMESTAMP,  LOCK_NAME VARCHAR(32),  LOCK_OBJECT_TYPE_ID CHAR (1) FOR BIT DATA,  LOCK_OBJECT_TYPE VARCHAR(32),  LOCK_MODE VARCHAR(3),  LOCK_CURRENT_MODE VARCHAR(3),  LOCK_MODE_REQUESTED VARCHAR(3),  LOCK_STATUS CHAR(1),  LOCK_ESCALATION CHAR(1),  LOCK_ATTRIBUTES CHAR(16),  LOCK_RRIID BIGINT,  LOCK_COUNT BIGINT,  TBSP_ID BIGINT,  TAB_FILE_ID BIGINT,  SUBSECTION_NUMBER BIGINT,  REQ_APPLICATION_HANDLE BIGINT,  REQ_AGENT_TID BIGINT,  REQ_MEMBER SMALLINT,  REQ_EXECUTABLE_ID VARCHAR (32) FOR BIT DATA,  HLD_APPLICATION_HANDLE BIGINT,  HLD_MEMBER SMALLINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_APPL_LOCKWAIT"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetApplLockwait"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_BUFFERPOOL" (BP_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (BP_NAME VARCHAR(128),  MEMBER SMALLINT,  AUTOMATIC SMALLINT,  DIRECT_READS BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_REQS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  VECTORED_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  BLOCK_IOS BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_DATA_GBP_L_READS BIGINT,  POOL_DATA_GBP_P_READS BIGINT,  POOL_DATA_LBP_PAGES_FOUND BIGINT,  POOL_DATA_GBP_INVALID_PAGES BIGINT,  POOL_INDEX_GBP_L_READS BIGINT,  POOL_INDEX_GBP_P_READS BIGINT,  POOL_INDEX_LBP_PAGES_FOUND BIGINT,  POOL_INDEX_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_DATA_GBP_L_READS BIGINT,  POOL_ASYNC_DATA_GBP_P_READS BIGINT,  POOL_ASYNC_DATA_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_DATA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_INDEX_GBP_L_READS BIGINT,  POOL_ASYNC_INDEX_GBP_P_READS BIGINT,  POOL_ASYNC_INDEX_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_INDEX_GBP_INVALID_PAGES BIGINT,  POOL_XDA_GBP_L_READS BIGINT,  POOL_XDA_GBP_P_READS BIGINT,  POOL_XDA_LBP_PAGES_FOUND BIGINT,  POOL_XDA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_XDA_GBP_L_READS BIGINT,  POOL_ASYNC_XDA_GBP_P_READS BIGINT,  POOL_ASYNC_XDA_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_XDA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  BP_CUR_BUFFSZ BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_BUFFERPOOL"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetBufferpoolv97fp5"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_CONNECTION" (APPLICATION_HANDLE BIGINT, 
		MEMBER INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  APPLICATION_NAME VARCHAR(128),  APPLICATION_ID VARCHAR(128),  MEMBER SMALLINT,  CLIENT_WRKSTNNAME VARCHAR(255),  CLIENT_ACCTNG VARCHAR(255),  CLIENT_USERID VARCHAR(255),  CLIENT_APPLNAME VARCHAR(255),  CLIENT_PID BIGINT,  CLIENT_PRDID VARCHAR(128),  CLIENT_PLATFORM VARCHAR(12),  CLIENT_PROTOCOL VARCHAR(10),  SYSTEM_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  COORD_MEMBER SMALLINT,  CONNECTION_START_TIME TIMESTAMP,  ACT_ABORTED_TOTAL BIGINT,  ACT_COMPLETED_TOTAL BIGINT,  ACT_REJECTED_TOTAL BIGINT,  AGENT_WAIT_TIME BIGINT,  AGENT_WAITS_TOTAL BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  CLIENT_IDLE_WAIT_TIME BIGINT,  DEADLOCKS BIGINT,  DIRECT_READS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_TIME BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_RECVS_TOTAL BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_SENDS_TOTAL BIGINT,  FCM_RECV_WAIT_TIME BIGINT,  FCM_SEND_WAIT_TIME BIGINT,  IPC_RECV_VOLUME BIGINT,  IPC_RECV_WAIT_TIME BIGINT,  IPC_RECVS_TOTAL BIGINT,  IPC_SEND_VOLUME BIGINT,  IPC_SEND_WAIT_TIME BIGINT,  IPC_SENDS_TOTAL BIGINT,  LOCK_ESCALS BIGINT,  LOCK_TIMEOUTS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_WAITS BIGINT,  LOG_BUFFER_WAIT_TIME BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  LOG_DISK_WAIT_TIME BIGINT,  LOG_DISK_WAITS_TOTAL BIGINT,  NUM_LOCKS_HELD BIGINT,  RQSTS_COMPLETED_TOTAL BIGINT,  ROWS_MODIFIED BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  TCPIP_RECV_VOLUME BIGINT,  TCPIP_SEND_VOLUME BIGINT,  TCPIP_RECV_WAIT_TIME BIGINT,  TCPIP_RECVS_TOTAL BIGINT,  TCPIP_SEND_WAIT_TIME BIGINT,  TCPIP_SENDS_TOTAL BIGINT,  TOTAL_APP_RQST_TIME BIGINT,  TOTAL_RQST_TIME BIGINT,  WLM_QUEUE_TIME_TOTAL BIGINT,  WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT,  TOTAL_CPU_TIME BIGINT,  TOTAL_WAIT_TIME BIGINT,  APP_RQSTS_COMPLETED_TOTAL BIGINT,  TOTAL_SECTION_SORT_TIME BIGINT,  TOTAL_SECTION_SORT_PROC_TIME BIGINT,  TOTAL_SECTION_SORTS BIGINT,  TOTAL_SORTS BIGINT,  POST_THRESHOLD_SORTS BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_COMPILE_TIME BIGINT,  TOTAL_COMPILE_PROC_TIME BIGINT,  TOTAL_COMPILATIONS BIGINT,  TOTAL_IMPLICIT_COMPILE_TIME BIGINT,  TOTAL_IMPLICIT_COMPILE_PROC_TIME BIGINT,  TOTAL_IMPLICIT_COMPILATIONS BIGINT,  TOTAL_SECTION_TIME BIGINT,  TOTAL_SECTION_PROC_TIME BIGINT,  TOTAL_APP_SECTION_EXECUTIONS BIGINT,  TOTAL_ACT_TIME BIGINT,  TOTAL_ACT_WAIT_TIME BIGINT,  ACT_RQSTS_TOTAL BIGINT,  TOTAL_ROUTINE_TIME BIGINT,  TOTAL_ROUTINE_INVOCATIONS BIGINT,  TOTAL_COMMIT_TIME BIGINT,  TOTAL_COMMIT_PROC_TIME BIGINT,  TOTAL_APP_COMMITS BIGINT,  INT_COMMITS BIGINT,  TOTAL_ROLLBACK_TIME BIGINT,  TOTAL_ROLLBACK_PROC_TIME BIGINT,  TOTAL_APP_ROLLBACKS BIGINT,  INT_ROLLBACKS BIGINT,  TOTAL_RUNSTATS_TIME BIGINT,  TOTAL_RUNSTATS_PROC_TIME BIGINT,  TOTAL_RUNSTATS BIGINT,  TOTAL_REORG_TIME BIGINT,  TOTAL_REORG_PROC_TIME BIGINT,  TOTAL_REORGS BIGINT,  TOTAL_LOAD_TIME BIGINT,  TOTAL_LOAD_PROC_TIME BIGINT,  TOTAL_LOADS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  THRESH_VIOLATIONS BIGINT,  NUM_LW_THRESH_EXCEEDED BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_CONNECTION"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetConnection"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_CONNECTION_DETAILS" (APPLICATION_HANDLE BIGINT, 
		MEMBER INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  MEMBER SMALLINT,  DETAILS BLOB(1048576))
	SPECIFIC "SYSPROC"."MON_GET_CONNECTION_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetConnectionDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_CONTAINER" (TBSP_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_ID BIGINT,  MEMBER SMALLINT,  CONTAINER_TYPE VARCHAR(16),  STRIPE_SET BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  PAGES_READ BIGINT,  PAGES_WRITTEN BIGINT,  VECTORED_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  BLOCK_IOS BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  ACCESSIBLE SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_CONTAINER"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetContainer"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_EXTENT_MOVEMENT_STATUS" (TBSP_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  MEMBER SMALLINT,  CURRENT_EXTENT INTEGER,  LAST_EXTENT INTEGER,  NUM_EXTENTS_MOVED INTEGER,  NUM_EXTENTS_LEFT INTEGER,  TOTAL_MOVE_TIME BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_EXTENT_MOVEMENT_STATUS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetExtentMovementStatus"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_FCM" (MEMBER INTEGER)
	RETURNS TABLE (HOSTNAME VARCHAR(128),  MEMBER SMALLINT,  BUFF_MAX BIGINT,  BUFF_TOTAL BIGINT,  BUFF_FREE BIGINT,  BUFF_FREE_BOTTOM BIGINT,  BUFF_AUTO_TUNING SMALLINT,  CH_MAX BIGINT,  CH_TOTAL BIGINT,  CH_FREE BIGINT,  CH_FREE_BOTTOM BIGINT,  CH_AUTO_TUNING SMALLINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_FCM"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetFcm"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_FCM_CONNECTION_LIST" (MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  REMOTE_MEMBER SMALLINT,  CONNECTION_STATUS VARCHAR(16),  TOTAL_BUFFERS_SENT BIGINT,  TOTAL_BUFFERS_RCVD BIGINT,  FCM_CONGESTION_TIME BIGINT,  FCM_CONGESTED_SENDS BIGINT,  FCM_NUM_CONGESTION_TIMEOUTS BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_MESSAGE_SEND_VOLUME BIGINT,  FCM_MESSAGE_RECV_VOLUME BIGINT,  FCM_TQ_SEND_VOLUME BIGINT,  FCM_TQ_RECV_VOLUME BIGINT,  FCM_NUM_CONN_LOST BIGINT,  FCM_NUM_CONN_TIMEOUTS BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_FCM_CONNECTION_LIST"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetFcmConnectionList"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_INDEX" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  IID SMALLINT,  MEMBER SMALLINT,  DATA_PARTITION_ID INTEGER,  NLEAF BIGINT,  NLEVELS SMALLINT,  INDEX_SCANS BIGINT,  INDEX_ONLY_SCANS BIGINT,  KEY_UPDATES BIGINT,  INCLUDE_COL_UPDATES BIGINT,  PSEUDO_DELETES BIGINT,  DEL_KEYS_CLEANED BIGINT,  ROOT_NODE_SPLITS BIGINT,  INT_NODE_SPLITS BIGINT,  BOUNDARY_LEAF_NODE_SPLITS BIGINT,  NONBOUNDARY_LEAF_NODE_SPLITS BIGINT,  PAGE_ALLOCATIONS BIGINT,  PSEUDO_EMPTY_PAGES BIGINT,  EMPTY_PAGES_REUSED BIGINT,  EMPTY_PAGES_DELETED BIGINT,  PAGES_MERGED BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_INDEX"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetIndex"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_LOCKS" (SEARCH_ARGS CLOB(1024), 
		MEMBER INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  MEMBER SMALLINT,  LOCK_NAME VARCHAR(32),  LOCK_OBJECT_TYPE_ID CHAR (1) FOR BIT DATA,  LOCK_OBJECT_TYPE VARCHAR(32),  LOCK_MODE VARCHAR(3),  LOCK_CURRENT_MODE VARCHAR(3),  LOCK_STATUS CHAR(1),  LOCK_ATTRIBUTES CHAR(16),  LOCK_RELEASE_FLAGS CHAR(16),  LOCK_RRIID BIGINT,  LOCK_COUNT BIGINT,  LOCK_HOLD_COUNT BIGINT,  TBSP_ID BIGINT,  TAB_FILE_ID BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_LOCKS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetLocks"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_MEMORY_POOL" (MEMORY_SET_TYPE VARCHAR(32), 
		DB_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  HOST_NAME VARCHAR(255),  DB_NAME VARCHAR(128),  MEMORY_SET_TYPE VARCHAR(32),  MEMORY_POOL_TYPE VARCHAR(32),  MEMORY_POOL_ID BIGINT,  APPLICATION_HANDLE BIGINT,  EDU_ID BIGINT,  MEMORY_POOL_USED BIGINT,  MEMORY_POOL_USED_HWM BIGINT)
	SPECIFIC "SYSPROC"."MON_GET_MEMORY_POOL"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetMemoryPool"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_MEMORY_SET" (MEMORY_SET_TYPE VARCHAR(32), 
		DB_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  HOST_NAME VARCHAR(255),  DB_NAME VARCHAR(128),  MEMORY_SET_TYPE VARCHAR(32),  MEMORY_SET_ID BIGINT,  MEMORY_SET_SIZE BIGINT,  MEMORY_SET_COMMITTED BIGINT,  MEMORY_SET_USED BIGINT,  MEMORY_SET_USED_HWM BIGINT)
	SPECIFIC "SYSPROC"."MON_GET_MEMORY_SET"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetMemorySet"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_PKG_CACHE_STMT" (SECTION_TYPE CHAR(1), 
		EXECUTABLE_ID VARCHAR (32) FOR BIT DATA, 
		SEARCH_ARGS CLOB(1024), 
		MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  SECTION_TYPE CHAR(1),  INSERT_TIMESTAMP TIMESTAMP,  EXECUTABLE_ID VARCHAR (32) FOR BIT DATA,  PACKAGE_SCHEMA VARCHAR(128),  PACKAGE_NAME VARCHAR(128),  PACKAGE_VERSION_ID VARCHAR(64),  SECTION_NUMBER BIGINT,  EFFECTIVE_ISOLATION CHAR(2),  NUM_EXECUTIONS BIGINT,  NUM_EXEC_WITH_METRICS BIGINT,  PREP_TIME BIGINT,  TOTAL_ACT_TIME BIGINT,  TOTAL_ACT_WAIT_TIME BIGINT,  TOTAL_CPU_TIME BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  LOCK_WAIT_TIME BIGINT,  TOTAL_SECTION_SORT_TIME BIGINT,  TOTAL_SECTION_SORT_PROC_TIME BIGINT,  TOTAL_SECTION_SORTS BIGINT,  LOCK_ESCALS BIGINT,  LOCK_WAITS BIGINT,  ROWS_MODIFIED BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  DIRECT_READS BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_REQS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  TOTAL_SORTS BIGINT,  POST_THRESHOLD_SORTS BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  WLM_QUEUE_TIME_TOTAL BIGINT,  WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT,  DEADLOCKS BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_RECVS_TOTAL BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_SENDS_TOTAL BIGINT,  FCM_RECV_WAIT_TIME BIGINT,  FCM_SEND_WAIT_TIME BIGINT,  LOCK_TIMEOUTS BIGINT,  LOG_BUFFER_WAIT_TIME BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  LOG_DISK_WAIT_TIME BIGINT,  LOG_DISK_WAITS_TOTAL BIGINT,  LAST_METRICS_UPDATE TIMESTAMP,  NUM_COORD_EXEC BIGINT,  NUM_COORD_EXEC_WITH_METRICS BIGINT,  VALID CHAR(1),  TOTAL_ROUTINE_TIME BIGINT,  TOTAL_ROUTINE_INVOCATIONS BIGINT,  ROUTINE_ID BIGINT,  STMT_TYPE_ID VARCHAR(32),  QUERY_COST_ESTIMATE BIGINT,  STMT_PKG_CACHE_ID BIGINT,  COORD_STMT_EXEC_TIME BIGINT,  STMT_EXEC_TIME BIGINT,  TOTAL_SECTION_TIME BIGINT,  TOTAL_SECTION_PROC_TIME BIGINT,  TOTAL_ROUTINE_NON_SECT_TIME BIGINT,  TOTAL_ROUTINE_NON_SECT_PROC_TIME BIGINT,  STMT_TEXT CLOB(2097152),  COMP_ENV_DESC BLOB(10240),  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_PKG_CACHE_STMT"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetPkgCacheStmt"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_PKG_CACHE_STMT_DETAILS" (SECTION_TYPE CHAR(1), 
		EXECUTABLE_ID VARCHAR (32) FOR BIT DATA, 
		SEARCH_ARGS CLOB(1024), 
		MEMBER INTEGER)
	RETURNS TABLE (MEMBER SMALLINT,  SECTION_TYPE CHAR(1),  EXECUTABLE_ID VARCHAR (32) FOR BIT DATA,  DETAILS BLOB(8388608))
	SPECIFIC "SYSPROC"."MON_GET_PKG_CACHE_STMT_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetPkgCacheStmtDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_SERVICE_SUBCLASS" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  SERVICE_CLASS_ID INTEGER,  MEMBER SMALLINT,  ACT_ABORTED_TOTAL BIGINT,  ACT_COMPLETED_TOTAL BIGINT,  ACT_REJECTED_TOTAL BIGINT,  AGENT_WAIT_TIME BIGINT,  AGENT_WAITS_TOTAL BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  CLIENT_IDLE_WAIT_TIME BIGINT,  DEADLOCKS BIGINT,  DIRECT_READS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_TIME BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_RECVS_TOTAL BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_SENDS_TOTAL BIGINT,  FCM_RECV_WAIT_TIME BIGINT,  FCM_SEND_WAIT_TIME BIGINT,  IPC_RECV_VOLUME BIGINT,  IPC_RECV_WAIT_TIME BIGINT,  IPC_RECVS_TOTAL BIGINT,  IPC_SEND_VOLUME BIGINT,  IPC_SEND_WAIT_TIME BIGINT,  IPC_SENDS_TOTAL BIGINT,  LOCK_ESCALS BIGINT,  LOCK_TIMEOUTS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_WAITS BIGINT,  LOG_BUFFER_WAIT_TIME BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  LOG_DISK_WAIT_TIME BIGINT,  LOG_DISK_WAITS_TOTAL BIGINT,  RQSTS_COMPLETED_TOTAL BIGINT,  ROWS_MODIFIED BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  TCPIP_RECV_VOLUME BIGINT,  TCPIP_SEND_VOLUME BIGINT,  TCPIP_RECV_WAIT_TIME BIGINT,  TCPIP_RECVS_TOTAL BIGINT,  TCPIP_SEND_WAIT_TIME BIGINT,  TCPIP_SENDS_TOTAL BIGINT,  TOTAL_APP_RQST_TIME BIGINT,  TOTAL_RQST_TIME BIGINT,  WLM_QUEUE_TIME_TOTAL BIGINT,  WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT,  TOTAL_RQST_MAPPED_IN BIGINT,  TOTAL_RQST_MAPPED_OUT BIGINT,  TOTAL_CPU_TIME BIGINT,  TOTAL_WAIT_TIME BIGINT,  APP_RQSTS_COMPLETED_TOTAL BIGINT,  TOTAL_SECTION_SORT_TIME BIGINT,  TOTAL_SECTION_SORT_PROC_TIME BIGINT,  TOTAL_SECTION_SORTS BIGINT,  TOTAL_SORTS BIGINT,  POST_THRESHOLD_SORTS BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_COMPILE_TIME BIGINT,  TOTAL_COMPILE_PROC_TIME BIGINT,  TOTAL_COMPILATIONS BIGINT,  TOTAL_IMPLICIT_COMPILE_TIME BIGINT,  TOTAL_IMPLICIT_COMPILE_PROC_TIME BIGINT,  TOTAL_IMPLICIT_COMPILATIONS BIGINT,  TOTAL_SECTION_TIME BIGINT,  TOTAL_SECTION_PROC_TIME BIGINT,  TOTAL_APP_SECTION_EXECUTIONS BIGINT,  TOTAL_ACT_TIME BIGINT,  TOTAL_ACT_WAIT_TIME BIGINT,  ACT_RQSTS_TOTAL BIGINT,  TOTAL_ROUTINE_TIME BIGINT,  TOTAL_ROUTINE_INVOCATIONS BIGINT,  TOTAL_COMMIT_TIME BIGINT,  TOTAL_COMMIT_PROC_TIME BIGINT,  TOTAL_APP_COMMITS BIGINT,  INT_COMMITS BIGINT,  TOTAL_ROLLBACK_TIME BIGINT,  TOTAL_ROLLBACK_PROC_TIME BIGINT,  TOTAL_APP_ROLLBACKS BIGINT,  INT_ROLLBACKS BIGINT,  TOTAL_RUNSTATS_TIME BIGINT,  TOTAL_RUNSTATS_PROC_TIME BIGINT,  TOTAL_RUNSTATS BIGINT,  TOTAL_REORG_TIME BIGINT,  TOTAL_REORG_PROC_TIME BIGINT,  TOTAL_REORGS BIGINT,  TOTAL_LOAD_TIME BIGINT,  TOTAL_LOAD_PROC_TIME BIGINT,  TOTAL_LOADS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  THRESH_VIOLATIONS BIGINT,  NUM_LW_THRESH_EXCEEDED BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_SERVICE_SUBCLASS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetServiceSubClass"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_SERVICE_SUBCLASS_DETAILS" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  SERVICE_CLASS_ID INTEGER,  MEMBER SMALLINT,  DETAILS BLOB(1048576))
	SPECIFIC "SYSPROC"."MON_GET_SERVICE_SUBCLASS_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetServiceSubClassDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_TABLE" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  MEMBER SMALLINT,  TAB_TYPE VARCHAR(14),  TAB_FILE_ID BIGINT,  DATA_PARTITION_ID INTEGER,  TBSP_ID BIGINT,  INDEX_TBSP_ID BIGINT,  LONG_TBSP_ID BIGINT,  TABLE_SCANS BIGINT,  ROWS_READ BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_DELETED BIGINT,  OVERFLOW_ACCESSES BIGINT,  OVERFLOW_CREATES BIGINT,  PAGE_REORGS BIGINT,  DATA_OBJECT_L_PAGES BIGINT,  LOB_OBJECT_L_PAGES BIGINT,  LONG_OBJECT_L_PAGES BIGINT,  INDEX_OBJECT_L_PAGES BIGINT,  XDA_OBJECT_L_PAGES BIGINT,  DBPARTITIONNUM SMALLINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_TABLE"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetTablev97fp5"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_TABLESPACE" (TBSP_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  MEMBER SMALLINT,  TBSP_TYPE VARCHAR(10),  TBSP_CONTENT_TYPE VARCHAR(10),  TBSP_PAGE_SIZE BIGINT,  TBSP_EXTENT_SIZE BIGINT,  TBSP_PREFETCH_SIZE BIGINT,  TBSP_CUR_POOL_ID BIGINT,  TBSP_NEXT_POOL_ID BIGINT,  FS_CACHING SMALLINT,  TBSP_REBALANCER_MODE VARCHAR(30),  TBSP_USING_AUTO_STORAGE SMALLINT,  TBSP_AUTO_RESIZE_ENABLED SMALLINT,  DIRECT_READS BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_REQS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  VECTORED_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  BLOCK_IOS BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  TBSP_STATE VARCHAR(256),  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_TOTAL_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  TBSP_MAX_PAGE_TOP BIGINT,  RECLAIMABLE_SPACE_ENABLED SMALLINT,  AUTO_STORAGE_HYBRID SMALLINT,  TBSP_PATHS_DROPPED SMALLINT,  POOL_DATA_GBP_L_READS BIGINT,  POOL_DATA_GBP_P_READS BIGINT,  POOL_DATA_LBP_PAGES_FOUND BIGINT,  POOL_DATA_GBP_INVALID_PAGES BIGINT,  POOL_INDEX_GBP_L_READS BIGINT,  POOL_INDEX_GBP_P_READS BIGINT,  POOL_INDEX_LBP_PAGES_FOUND BIGINT,  POOL_INDEX_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_DATA_GBP_L_READS BIGINT,  POOL_ASYNC_DATA_GBP_P_READS BIGINT,  POOL_ASYNC_DATA_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_DATA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_INDEX_GBP_L_READS BIGINT,  POOL_ASYNC_INDEX_GBP_P_READS BIGINT,  POOL_ASYNC_INDEX_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_INDEX_GBP_INVALID_PAGES BIGINT,  TABLESPACE_MIN_RECOVERY_TIME TIMESTAMP,  DBPARTITIONNUM SMALLINT,  POOL_XDA_GBP_L_READS BIGINT,  POOL_XDA_GBP_P_READS BIGINT,  POOL_XDA_LBP_PAGES_FOUND BIGINT,  POOL_XDA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_XDA_GBP_L_READS BIGINT,  POOL_ASYNC_XDA_GBP_P_READS BIGINT,  POOL_ASYNC_XDA_LBP_PAGES_FOUND BIGINT,  POOL_ASYNC_XDA_GBP_INVALID_PAGES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  TBSP_TRACKMOD_STATE VARCHAR(32),  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_TABLESPACE"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetTablespacev97fp5"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_UNIT_OF_WORK" (APPLICATION_HANDLE BIGINT, 
		MEMBER INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  SERVICE_CLASS_ID INTEGER,  MEMBER SMALLINT,  COORD_MEMBER SMALLINT,  APPLICATION_HANDLE BIGINT,  APPLICATION_ID VARCHAR(128),  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  WORKLOAD_OCCURRENCE_STATE VARCHAR(32),  CLIENT_WRKSTNNAME VARCHAR(255),  CLIENT_ACCTNG VARCHAR(255),  CLIENT_USERID VARCHAR(255),  CLIENT_APPLNAME VARCHAR(255),  UOW_START_TIME TIMESTAMP,  SESSION_AUTH_ID VARCHAR(128),  ACT_ABORTED_TOTAL BIGINT,  ACT_COMPLETED_TOTAL BIGINT,  ACT_REJECTED_TOTAL BIGINT,  AGENT_WAIT_TIME BIGINT,  AGENT_WAITS_TOTAL BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  CLIENT_IDLE_WAIT_TIME BIGINT,  DEADLOCKS BIGINT,  DIRECT_READS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_TIME BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_RECVS_TOTAL BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_SENDS_TOTAL BIGINT,  FCM_RECV_WAIT_TIME BIGINT,  FCM_SEND_WAIT_TIME BIGINT,  IPC_RECV_VOLUME BIGINT,  IPC_RECV_WAIT_TIME BIGINT,  IPC_RECVS_TOTAL BIGINT,  IPC_SEND_VOLUME BIGINT,  IPC_SEND_WAIT_TIME BIGINT,  IPC_SENDS_TOTAL BIGINT,  LOCK_ESCALS BIGINT,  LOCK_TIMEOUTS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_WAITS BIGINT,  LOG_BUFFER_WAIT_TIME BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  LOG_DISK_WAIT_TIME BIGINT,  LOG_DISK_WAITS_TOTAL BIGINT,  NUM_LOCKS_HELD BIGINT,  RQSTS_COMPLETED_TOTAL BIGINT,  ROWS_MODIFIED BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  TCPIP_RECV_VOLUME BIGINT,  TCPIP_SEND_VOLUME BIGINT,  TCPIP_RECV_WAIT_TIME BIGINT,  TCPIP_RECVS_TOTAL BIGINT,  TCPIP_SEND_WAIT_TIME BIGINT,  TCPIP_SENDS_TOTAL BIGINT,  TOTAL_APP_RQST_TIME BIGINT,  TOTAL_RQST_TIME BIGINT,  WLM_QUEUE_TIME_TOTAL BIGINT,  WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT,  TOTAL_CPU_TIME BIGINT,  TOTAL_WAIT_TIME BIGINT,  APP_RQSTS_COMPLETED_TOTAL BIGINT,  TOTAL_SECTION_SORT_TIME BIGINT,  TOTAL_SECTION_SORT_PROC_TIME BIGINT,  TOTAL_SECTION_SORTS BIGINT,  TOTAL_SORTS BIGINT,  POST_THRESHOLD_SORTS BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_COMPILE_TIME BIGINT,  TOTAL_COMPILE_PROC_TIME BIGINT,  TOTAL_COMPILATIONS BIGINT,  TOTAL_IMPLICIT_COMPILE_TIME BIGINT,  TOTAL_IMPLICIT_COMPILE_PROC_TIME BIGINT,  TOTAL_IMPLICIT_COMPILATIONS BIGINT,  TOTAL_SECTION_TIME BIGINT,  TOTAL_SECTION_PROC_TIME BIGINT,  TOTAL_APP_SECTION_EXECUTIONS BIGINT,  TOTAL_ACT_TIME BIGINT,  TOTAL_ACT_WAIT_TIME BIGINT,  ACT_RQSTS_TOTAL BIGINT,  TOTAL_ROUTINE_TIME BIGINT,  TOTAL_ROUTINE_INVOCATIONS BIGINT,  TOTAL_COMMIT_TIME BIGINT,  TOTAL_COMMIT_PROC_TIME BIGINT,  TOTAL_APP_COMMITS BIGINT,  INT_COMMITS BIGINT,  TOTAL_ROLLBACK_TIME BIGINT,  TOTAL_ROLLBACK_PROC_TIME BIGINT,  TOTAL_APP_ROLLBACKS BIGINT,  INT_ROLLBACKS BIGINT,  TOTAL_RUNSTATS_TIME BIGINT,  TOTAL_RUNSTATS_PROC_TIME BIGINT,  TOTAL_RUNSTATS BIGINT,  TOTAL_REORG_TIME BIGINT,  TOTAL_REORG_PROC_TIME BIGINT,  TOTAL_REORGS BIGINT,  TOTAL_LOAD_TIME BIGINT,  TOTAL_LOAD_PROC_TIME BIGINT,  TOTAL_LOADS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  THRESH_VIOLATIONS BIGINT,  NUM_LW_THRESH_EXCEEDED BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_UNIT_OF_WORK"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetUnitOfWork"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_UNIT_OF_WORK_DETAILS" (APPLICATION_HANDLE BIGINT, 
		MEMBER INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  SERVICE_CLASS_ID INTEGER,  MEMBER SMALLINT,  COORD_MEMBER SMALLINT,  APPLICATION_HANDLE BIGINT,  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  DETAILS BLOB(1048576))
	SPECIFIC "SYSPROC"."MON_GET_UNIT_OF_WORK_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetUnitOfWorkDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_WORKLOAD" (WORKLOAD_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (WORKLOAD_NAME VARCHAR(128),  WORKLOAD_ID INTEGER,  MEMBER SMALLINT,  ACT_ABORTED_TOTAL BIGINT,  ACT_COMPLETED_TOTAL BIGINT,  ACT_REJECTED_TOTAL BIGINT,  AGENT_WAIT_TIME BIGINT,  AGENT_WAITS_TOTAL BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  CLIENT_IDLE_WAIT_TIME BIGINT,  DEADLOCKS BIGINT,  DIRECT_READS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_WRITE_TIME BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  FCM_RECV_VOLUME BIGINT,  FCM_RECVS_TOTAL BIGINT,  FCM_SEND_VOLUME BIGINT,  FCM_SENDS_TOTAL BIGINT,  FCM_RECV_WAIT_TIME BIGINT,  FCM_SEND_WAIT_TIME BIGINT,  IPC_RECV_VOLUME BIGINT,  IPC_RECV_WAIT_TIME BIGINT,  IPC_RECVS_TOTAL BIGINT,  IPC_SEND_VOLUME BIGINT,  IPC_SEND_WAIT_TIME BIGINT,  IPC_SENDS_TOTAL BIGINT,  LOCK_ESCALS BIGINT,  LOCK_TIMEOUTS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_WAITS BIGINT,  LOG_BUFFER_WAIT_TIME BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  LOG_DISK_WAIT_TIME BIGINT,  LOG_DISK_WAITS_TOTAL BIGINT,  RQSTS_COMPLETED_TOTAL BIGINT,  ROWS_MODIFIED BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  TCPIP_RECV_VOLUME BIGINT,  TCPIP_SEND_VOLUME BIGINT,  TCPIP_RECV_WAIT_TIME BIGINT,  TCPIP_RECVS_TOTAL BIGINT,  TCPIP_SEND_WAIT_TIME BIGINT,  TCPIP_SENDS_TOTAL BIGINT,  TOTAL_APP_RQST_TIME BIGINT,  TOTAL_RQST_TIME BIGINT,  WLM_QUEUE_TIME_TOTAL BIGINT,  WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT,  TOTAL_CPU_TIME BIGINT,  TOTAL_WAIT_TIME BIGINT,  APP_RQSTS_COMPLETED_TOTAL BIGINT,  TOTAL_SECTION_SORT_TIME BIGINT,  TOTAL_SECTION_SORT_PROC_TIME BIGINT,  TOTAL_SECTION_SORTS BIGINT,  TOTAL_SORTS BIGINT,  POST_THRESHOLD_SORTS BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_COMPILE_TIME BIGINT,  TOTAL_COMPILE_PROC_TIME BIGINT,  TOTAL_COMPILATIONS BIGINT,  TOTAL_IMPLICIT_COMPILE_TIME BIGINT,  TOTAL_IMPLICIT_COMPILE_PROC_TIME BIGINT,  TOTAL_IMPLICIT_COMPILATIONS BIGINT,  TOTAL_SECTION_TIME BIGINT,  TOTAL_SECTION_PROC_TIME BIGINT,  TOTAL_APP_SECTION_EXECUTIONS BIGINT,  TOTAL_ACT_TIME BIGINT,  TOTAL_ACT_WAIT_TIME BIGINT,  ACT_RQSTS_TOTAL BIGINT,  TOTAL_ROUTINE_TIME BIGINT,  TOTAL_ROUTINE_INVOCATIONS BIGINT,  TOTAL_COMMIT_TIME BIGINT,  TOTAL_COMMIT_PROC_TIME BIGINT,  TOTAL_APP_COMMITS BIGINT,  INT_COMMITS BIGINT,  TOTAL_ROLLBACK_TIME BIGINT,  TOTAL_ROLLBACK_PROC_TIME BIGINT,  TOTAL_APP_ROLLBACKS BIGINT,  INT_ROLLBACKS BIGINT,  TOTAL_RUNSTATS_TIME BIGINT,  TOTAL_RUNSTATS_PROC_TIME BIGINT,  TOTAL_RUNSTATS BIGINT,  TOTAL_REORG_TIME BIGINT,  TOTAL_REORG_PROC_TIME BIGINT,  TOTAL_REORGS BIGINT,  TOTAL_LOAD_TIME BIGINT,  TOTAL_LOAD_PROC_TIME BIGINT,  TOTAL_LOADS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  THRESH_VIOLATIONS BIGINT,  NUM_LW_THRESH_EXCEEDED BIGINT,  ADDITIONAL_DETAILS BLOB(102400))
	SPECIFIC "SYSPROC"."MON_GET_WORKLOAD"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetWorkload"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."MON_GET_WORKLOAD_DETAILS" (WORKLOAD_NAME VARCHAR(128), 
		MEMBER INTEGER)
	RETURNS TABLE (WORKLOAD_NAME VARCHAR(128),  WORKLOAD_ID INTEGER,  MEMBER SMALLINT,  DETAILS BLOB(1048576))
	SPECIFIC "SYSPROC"."MON_GET_WORKLOAD_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!monGetWorkloadDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."OPT_MIGRATE_PROF" (BLOB(2097152))
	RETURNS TABLE (PROFILE BLOB(2097152),  ERROR_MSG VARCHAR(4096))
	SPECIFIC "SYSPROC"."OPT_MIGRATE_PROF"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!sqlMigrateOptProfile"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 1;

CREATE FUNCTION "SYSPROC"."PD_GET_DIAG_HIST" (VARCHAR(20), 
		VARCHAR(30), 
		VARCHAR(18), 
		TIMESTAMP, 
		TIMESTAMP)
	RETURNS TABLE (FACILITY VARCHAR(20),  RECTYPE VARCHAR(3),  TIMESTAMP TIMESTAMP,  TIMEZONE INTEGER,  INSTANCENAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LEVEL CHAR(1),  IMPACT VARCHAR(18),  DBNAME VARCHAR(128),  EDU_ID BIGINT,  EDUNAME VARCHAR(64),  PID BIGINT,  PROCESS_NAME VARCHAR(255),  TID BIGINT,  APPLNAME VARCHAR(255),  APPL_ID VARCHAR(64),  APPLHANDLE VARCHAR(9),  AUTH_ID VARCHAR(30),  PRODUCT VARCHAR(50),  COMPONENT VARCHAR(255),  FUNCTION VARCHAR(255),  PROBE INTEGER,  CALLEDPRODUCT VARCHAR(50),  CALLEDCOMPONENT VARCHAR(255),  CALLEDFUNCTION VARCHAR(255),  OSERR INTEGER,  RETCODE INTEGER,  MSGNUM INTEGER,  MSGTYPE CHAR(3),  MSG CLOB(16384),  OBJTYPE VARCHAR(64),  OBJNAME VARCHAR(255),  OBJNAME_QUALIFIER VARCHAR(255),  EVENTTYPE VARCHAR(24),  EVENTDESC VARCHAR(256),  FIRST_EVENTQUALIFIERTYPE VARCHAR(64),  FIRST_EVENTQUALIFIER CLOB(16384),  SECOND_EVENTQUALIFIERTYPE VARCHAR(64),  SECOND_EVENTQUALIFIER CLOB(16384),  THIRD_EVENTQUALIFIERTYPE VARCHAR(64),  THIRD_EVENTQUALIFIER CLOB(16384),  EVENTSTATE VARCHAR(255),  EVENTATTRIBUTE VARCHAR(255),  EVENTSTACK CLOB(16384),  CALLSTACK CLOB(16384),  DUMPFILE CLOB(5000),  FULLREC CLOB(16384))
	SPECIFIC "SYSPROC"."PD_GET_DIAG_HIST"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!pd_get_diag_hist"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 256;

CREATE FUNCTION "SYSPROC"."PD_GET_LOG_MSGS" (TIMESTAMP)
	RETURNS TABLE (TIMESTAMP TIMESTAMP,  TIMEZONE INTEGER,  INSTANCENAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  DBNAME VARCHAR(128),  PID BIGINT,  PROCESSNAME VARCHAR(255),  TID BIGINT,  APPL_ID VARCHAR(64),  COMPONENT VARCHAR(255),  FUNCTION VARCHAR(255),  PROBE INTEGER,  MSGNUM INTEGER,  MSGTYPE CHAR(3),  MSGSEVERITY CHAR(1),  MSG CLOB(16384))
	SPECIFIC "SYSPROC"."PD_GET_LOG_MSGS"
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!pd_get_log_msgs"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 256;

CREATE FUNCTION "SYSPROC"."POLICY_VALIDATE" (MED VARCHAR(128), 
		POLICY BLOB(2097152))
	RETURNS INTEGER
	SPECIFIC "SYSPROC"."POLICY_VALIDATE"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2policy!db2PolicyValidateUdf"
	FENCED THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."REG_LIST_VARIABLES" ()
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  REG_VAR_NAME VARCHAR(256),  REG_VAR_VALUE VARCHAR(2048),  IS_AGGREGATE SMALLINT,  AGGREGATE_NAME VARCHAR(256),  LEVEL CHAR(1))
	SPECIFIC "SYSPROC"."REG_LIST_VARIABLES"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!reg_list_variables"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_AGENT" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  AGENT_PID BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_AGENT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_agent"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_APPL" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  DEADLOCKS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  OPEN_REM_CURS BIGINT,  OPEN_REM_CURS_BLK BIGINT,  REJ_CURS_BLK BIGINT,  ACC_CURS_BLK BIGINT,  SQL_REQS_SINCE_COMMIT BIGINT,  LOCK_TIMEOUTS BIGINT,  INT_ROWS_INSERTED BIGINT,  OPEN_LOC_CURS BIGINT,  OPEN_LOC_CURS_BLK BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_HEAP_FULL BIGINT,  NUM_AGENTS BIGINT,  AGENTS_STOLEN BIGINT,  ASSOCIATED_AGENTS_TOP BIGINT,  APPL_PRIORITY BIGINT,  APPL_PRIORITY_TYPE BIGINT,  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  LOCKS_WAITING BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  APPL_IDLE_TIME BIGINT,  UOW_LOCK_WAIT_TIME BIGINT,  UOW_COMP_STATUS BIGINT,  AGENT_USR_CPU_TIME_S BIGINT,  AGENT_USR_CPU_TIME_MS BIGINT,  AGENT_SYS_CPU_TIME_S BIGINT,  AGENT_SYS_CPU_TIME_MS BIGINT,  APPL_CON_TIME TIMESTAMP,  CONN_COMPLETE_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  UOW_START_TIME TIMESTAMP,  UOW_STOP_TIME TIMESTAMP,  PREV_UOW_STOP_TIME TIMESTAMP,  UOW_ELAPSED_TIME_S BIGINT,  UOW_ELAPSED_TIME_MS BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  INBOUND_COMM_ADDRESS VARCHAR(32))
	SPECIFIC "SYSPROC"."SNAPSHOT_APPL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_appl"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_APPL_INFO" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  APPL_STATUS BIGINT,  CODEPAGE_ID BIGINT,  NUM_ASSOC_AGENTS BIGINT,  COORD_PARTITION_NUM SMALLINT,  AUTHORITY_LVL BIGINT,  CLIENT_PID BIGINT,  COORD_AGENT_PID BIGINT,  STATUS_CHANGE_TIME TIMESTAMP,  CLIENT_PLATFORM SMALLINT,  CLIENT_PROTOCOL SMALLINT,  COUNTRY_CODE SMALLINT,  APPL_NAME VARCHAR(256),  APPL_ID VARCHAR(128),  SEQUENCE_NO VARCHAR(4),  AUTH_ID VARCHAR(128),  CLIENT_NNAME VARCHAR(128),  CLIENT_PRDID VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  CLIENT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  EXECUTION_ID VARCHAR(128),  CORR_TOKEN VARCHAR(128),  TPMON_CLIENT_USERID VARCHAR(256),  TPMON_CLIENT_WKSTN VARCHAR(256),  TPMON_CLIENT_APP VARCHAR(256),  TPMON_ACC_STR VARCHAR(200))
	SPECIFIC "SYSPROC"."SNAPSHOT_APPL_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_appl_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_BP" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128))
	SPECIFIC "SYSPROC"."SNAPSHOT_BP"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_bp"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_CNTRFS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_ID BIGINT,  CONTAINER_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_SIZE BIGINT,  NODENAME VARCHAR(256),  PARTITION_NUMBER SMALLINT,  FILESYSTEM_ID BIGINT,  FILESYSTEM_MOUNT_POINT VARCHAR(256),  FILESYSTEM_TYPE_NAME VARCHAR(256),  FILESYSTEM_DEVICE_TYPE BIGINT,  FILESYSTEM_TOTAL_SIZE BIGINT,  FILESYSTEM_FREE_SIZE BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_CNTRFS"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_cntrfs"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_CONTAINER" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_ID BIGINT,  TABLESPACE_NAME VARCHAR(128),  CONTAINER_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_TYPE SMALLINT,  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  ACCESSIBLE BIGINT,  STRIPE_SET BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_CONTAINER"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_container"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_DATABASE" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  TOTAL_LOG_USED BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  ROWS_READ BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  DB_STATUS BIGINT,  LOCK_TIMEOUTS BIGINT,  CONNECTIONS_TOP BIGINT,  DB_HEAP_TOP BIGINT,  INT_ROWS_INSERTED BIGINT,  LOG_READS BIGINT,  LOG_WRITES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_HEAP_FULL BIGINT,  CATALOG_PARTITION SMALLINT,  TOTAL_SEC_CONS BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  DB_CONN_TIME TIMESTAMP,  SQLM_ELM_LAST_RESET TIMESTAMP,  SQLM_ELM_LAST_BACKUP TIMESTAMP,  APPL_CON_TIME TIMESTAMP,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  DB_LOCATION INTEGER,  SERVER_PLATFORM INTEGER,  APPL_ID_OLDEST_XACT BIGINT,  CATALOG_PARTITION_NAME VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024))
	SPECIFIC "SYSPROC"."SNAPSHOT_DATABASE"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_database"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_DBM" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SORT_HEAP_ALLOCATED BIGINT,  POST_THRESHOLD_SORTS BIGINT,  PIPED_SORTS_REQUESTED BIGINT,  PIPED_SORTS_ACCEPTED BIGINT,  REM_CONS_IN BIGINT,  REM_CONS_IN_EXEC BIGINT,  LOCAL_CONS BIGINT,  LOCAL_CONS_IN_EXEC BIGINT,  CON_LOCAL_DBASES BIGINT,  AGENTS_REGISTERED BIGINT,  AGENTS_WAITING_ON_TOKEN BIGINT,  DB2_STATUS BIGINT,  AGENTS_REGISTERED_TOP BIGINT,  AGENTS_WAITING_TOP BIGINT,  COMM_PRIVATE_MEM BIGINT,  IDLE_AGENTS BIGINT,  AGENTS_FROM_POOL BIGINT,  AGENTS_CREATED_EMPTY_POOL BIGINT,  COORD_AGENTS_TOP BIGINT,  MAX_AGENT_OVERFLOWS BIGINT,  AGENTS_STOLEN BIGINT,  GW_TOTAL_CONS BIGINT,  GW_CUR_CONS BIGINT,  GW_CONS_WAIT_HOST BIGINT,  GW_CONS_WAIT_CLIENT BIGINT,  POST_THRESHOLD_HASH_JOINS BIGINT,  INACTIVE_GW_AGENTS BIGINT,  NUM_GW_CONN_SWITCHES BIGINT,  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP)
	SPECIFIC "SYSPROC"."SNAPSHOT_DBM"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_dbm_P"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_DYN_SQL" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  STMT_SORTS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_SYS_CPU_TIME BIGINT,  TOTAL_USR_CPU_TIME BIGINT,  STMT_TEXT CLOB(16777216))
	SPECIFIC "SYSPROC"."SNAPSHOT_DYN_SQL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_dyn_sql"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_FCM" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BUFF_FREE BIGINT,  BUFF_FREE_BOTTOM BIGINT,  MA_FREE BIGINT,  MA_FREE_BOTTOM BIGINT,  CE_FREE BIGINT,  CE_FREE_BOTTOM BIGINT,  RB_FREE BIGINT,  RB_FREE_BOTTOM BIGINT,  PARTITION_NUMBER SMALLINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_FCM"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_fcm_P"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_FCMNODE" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONNECTION_STATUS BIGINT,  TOTAL_BUFFERS_SENT BIGINT,  TOTAL_BUFFERS_RCVD BIGINT,  PARTITION_NUMBER SMALLINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_FCMNODE"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_fcmnode_P"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_LOCK" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  TABLE_FILE_ID BIGINT,  LOCK_OBJECT_TYPE BIGINT,  LOCK_MODE BIGINT,  LOCK_STATUS BIGINT,  LOCK_OBJECT_NAME BIGINT,  PARTITION_NUMBER SMALLINT,  LOCK_ESCALATION SMALLINT,  TABLE_NAME VARCHAR(128),  TABLE_SCHEMA VARCHAR(128),  TABLESPACE_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."SNAPSHOT_LOCK"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_lock"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_LOCKWAIT" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  SUBSECTION_NUMBER BIGINT,  LOCK_MODE BIGINT,  LOCK_OBJECT_TYPE BIGINT,  AGENT_ID_HOLDING_LK BIGINT,  LOCK_WAIT_START_TIME TIMESTAMP,  LOCK_MODE_REQUESTED BIGINT,  PARTITION_NUMBER SMALLINT,  LOCK_ESCALLATION SMALLINT,  TABLE_NAME VARCHAR(128),  TABLE_SCHEMA VARCHAR(128),  TABLESPACE_NAME VARCHAR(128),  APPL_ID_HOLDING_LK VARCHAR(128))
	SPECIFIC "SYSPROC"."SNAPSHOT_LOCKWAIT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_lockwait"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_QUIESCERS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_NAME VARCHAR(128),  QUIESCER_TBS_ID BIGINT,  QUIESCER_OBJ_ID BIGINT,  QUIESCER_AUTH_ID BIGINT,  QUIESCER_AGENT_ID BIGINT,  QUIESCER_STATE BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_QUIESCERS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_tbs_quiescer"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_RANGES" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_ID BIGINT,  TABLESPACE_NAME VARCHAR(128),  RANGE_NUMBER BIGINT,  RANGE_STRIPE_SET_NUMBER BIGINT,  RANGE_OFFSET BIGINT,  RANGE_MAX_PAGE BIGINT,  RANGE_MAX_EXTENT BIGINT,  RANGE_START_STRIPE BIGINT,  RANGE_END_STRIPE BIGINT,  RANGE_ADJUSTMENT BIGINT,  RANGE_NUM_CONTAINER BIGINT,  RANGE_CONTAINER_ID BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_RANGES"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_tbs_range"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_STATEMENT" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  NUM_AGENTS BIGINT,  AGENTS_TOP BIGINT,  STMT_TYPE BIGINT,  STMT_OPERATION BIGINT,  SECTION_NUMBER BIGINT,  QUERY_COST_ESTIMATE BIGINT,  QUERY_CARD_ESTIMATE BIGINT,  DEGREE_PARALLELISM BIGINT,  STMT_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_ROWS_INSERTED BIGINT,  FETCH_COUNT BIGINT,  STMT_START TIMESTAMP,  STMT_STOP TIMESTAMP,  STMT_USR_CPU_TIME_S BIGINT,  STMT_USR_CPU_TIME_MS BIGINT,  STMT_SYS_CPU_TIME_S BIGINT,  STMT_SYS_CPU_TIME_MS BIGINT,  STMT_ELAPSED_TIME_S BIGINT,  STMT_ELAPSED_TIME_MS BIGINT,  BLOCKING_CURSOR SMALLINT,  STMT_PARTITION_NUMBER SMALLINT,  CURSOR_NAME VARCHAR(128),  CREATOR VARCHAR(128),  PACKAGE_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216))
	SPECIFIC "SYSPROC"."SNAPSHOT_STATEMENT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_statement"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_SUBSECT" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  STMT_TEXT CLOB(16777216),  SS_EXEC_TIME BIGINT,  TQ_TOT_SEND_SPILLS BIGINT,  TQ_CUR_SEND_SPILLS BIGINT,  TQ_MAX_SEND_SPILLS BIGINT,  TQ_ROWS_READ BIGINT,  TQ_ROWS_WRITTEN BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  SS_USR_CPU_TIME BIGINT,  SS_SYS_CPU_TIME BIGINT,  SS_NUMBER INTEGER,  SS_STATUS INTEGER,  SS_PARTITION_NUMBER SMALLINT,  TQ_PARTITION_WAITED_FOR SMALLINT,  TQ_WAIT_FOR_ANY INTEGER,  TQ_ID_WAITING_ON INTEGER)
	SPECIFIC "SYSPROC"."SNAPSHOT_SUBSECT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_subsect"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_SWITCHES" (INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UOW_SW_STATE SMALLINT,  UOW_SW_TIME TIMESTAMP,  STATEMENT_SW_STATE SMALLINT,  STATEMENT_SW_TIME TIMESTAMP,  TABLE_SW_STATE SMALLINT,  TABLE_SW_TIME TIMESTAMP,  BUFFPOOL_SW_STATE SMALLINT,  BUFFPOOL_SW_TIME TIMESTAMP,  LOCK_SW_STATE SMALLINT,  LOCK_SW_TIME TIMESTAMP,  SORT_SW_STATE SMALLINT,  SORT_SW_TIME TIMESTAMP,  PARTITION_NUMBER SMALLINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_SWITCHES"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_switches_P"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_TABLE" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  ROWS_WRITTEN BIGINT,  ROWS_READ BIGINT,  OVERFLOW_ACCESSES BIGINT,  TABLE_FILE_ID BIGINT,  TABLE_TYPE BIGINT,  PAGE_REORGS BIGINT,  TABLE_NAME VARCHAR(128),  TABLE_SCHEMA VARCHAR(128))
	SPECIFIC "SYSPROC"."SNAPSHOT_TABLE"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_table"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_TBREORG" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLE_NAME VARCHAR(128),  TABLE_SCHEMA VARCHAR(128),  PAGE_REORGS BIGINT,  REORG_PHASE BIGINT,  REORG_MAX_PHASE INTEGER,  REORG_CURRENT_COUNTER BIGINT,  REORG_MAX_COUNTER BIGINT,  REORG_TYPE INTEGER,  REORG_STATUS SMALLINT,  REORG_COMPLETION INTEGER,  REORG_START TIMESTAMP,  REORG_END TIMESTAMP,  REORG_PHASE_START TIMESTAMP,  REORG_INDEX_ID BIGINT,  REORG_TBSPC_ID BIGINT,  PARTITION_NUMBER SMALLINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_TBREORG"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_tbreorg"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_TBS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  FILES_CLOSED BIGINT,  TABLESPACE_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."SNAPSHOT_TBS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_tbs"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_TBS_CFG" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABLESPACE_ID BIGINT,  TABLESPACE_NAME VARCHAR(128),  TABLESPACE_TYPE SMALLINT,  TABLESPACE_STATE BIGINT,  NUM_QUIESCERS BIGINT,  STATE_CHANGE_OBJ_ID BIGINT,  STATE_CHANGE_TBS_ID BIGINT,  MIN_RECOVERY_TIME TIMESTAMP,  TBS_CONTENTS_TYPE SMALLINT,  BUFFERPOOL_ID BIGINT,  NEXT_BUFFERPOOL_ID BIGINT,  PAGE_SIZE BIGINT,  EXTENT_SIZE BIGINT,  PREFETCH_SIZE BIGINT,  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  USED_PAGES BIGINT,  FREE_PAGES BIGINT,  PENDING_FREE_PAGES BIGINT,  HIGH_WATER_MARK BIGINT,  REBALANCER_MODE BIGINT,  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  LAST_EXTEND_MOVED BIGINT,  NUM_RANGES BIGINT,  NUM_CONTAINERS BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_TBS_CFG"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!snapshot_tbs_cfg"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_UTIL" (INTEGER)
	RETURNS TABLE (ID INTEGER,  PARTITION_NUMBER SMALLINT,  TYPE VARCHAR(255),  PRIORITY INTEGER,  DESCRIPTION VARCHAR(2048),  DATABASE VARCHAR(255),  START_TIME TIMESTAMP,  NUM_PHASES INTEGER,  CURRENT_PHASE INTEGER)
	SPECIFIC "SYSPROC"."SNAPSHOT_UTIL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!listUtilTabFuncGetUtil"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAPSHOT_UTIL_PROG" (INTEGER)
	RETURNS TABLE (ID INTEGER,  PARTITION_NUMBER SMALLINT,  PHASE_NUM INTEGER,  DESCRIPTION VARCHAR(2048),  START_TIME TIMESTAMP,  METRIC VARCHAR(255),  TOTAL_WORK BIGINT,  COMPLETED_WORK BIGINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_UTIL_PROG"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbappext!listUtilTabFuncGetUtilPhase"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_AGENT" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  AGENT_PID BIGINT,  LOCK_TIMEOUT_VAL BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_AGENT_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_agent_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_AGENT" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  AGENT_PID BIGINT,  LOCK_TIMEOUT_VAL BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_AGENT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_agent"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  AGENT_PID BIGINT,  POOL_ID VARCHAR(14),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_agent_memory_pool_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  AGENT_PID BIGINT,  POOL_ID VARCHAR(14),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_agent_memory_pool"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  INACT_STMTHIST_SZ BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  DEADLOCKS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  OPEN_REM_CURS BIGINT,  OPEN_REM_CURS_BLK BIGINT,  REJ_CURS_BLK BIGINT,  ACC_CURS_BLK BIGINT,  SQL_REQS_SINCE_COMMIT BIGINT,  LOCK_TIMEOUTS BIGINT,  INT_ROWS_INSERTED BIGINT,  OPEN_LOC_CURS BIGINT,  OPEN_LOC_CURS_BLK BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  NUM_AGENTS BIGINT,  AGENTS_STOLEN BIGINT,  ASSOCIATED_AGENTS_TOP BIGINT,  APPL_PRIORITY BIGINT,  APPL_PRIORITY_TYPE VARCHAR(16),  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  LOCKS_WAITING BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  APPL_IDLE_TIME BIGINT,  UOW_LOCK_WAIT_TIME BIGINT,  UOW_COMP_STATUS VARCHAR(14),  AGENT_USR_CPU_TIME_S BIGINT,  AGENT_USR_CPU_TIME_MS BIGINT,  AGENT_SYS_CPU_TIME_S BIGINT,  AGENT_SYS_CPU_TIME_MS BIGINT,  APPL_CON_TIME TIMESTAMP,  CONN_COMPLETE_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  UOW_START_TIME TIMESTAMP,  UOW_STOP_TIME TIMESTAMP,  PREV_UOW_STOP_TIME TIMESTAMP,  UOW_ELAPSED_TIME_S BIGINT,  UOW_ELAPSED_TIME_MS BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  INBOUND_COMM_ADDRESS VARCHAR(32),  LOCK_TIMEOUT_VAL BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  CAT_CACHE_SIZE_TOP BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  INACT_STMTHIST_SZ BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  DEADLOCKS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  OPEN_REM_CURS BIGINT,  OPEN_REM_CURS_BLK BIGINT,  REJ_CURS_BLK BIGINT,  ACC_CURS_BLK BIGINT,  SQL_REQS_SINCE_COMMIT BIGINT,  LOCK_TIMEOUTS BIGINT,  INT_ROWS_INSERTED BIGINT,  OPEN_LOC_CURS BIGINT,  OPEN_LOC_CURS_BLK BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  NUM_AGENTS BIGINT,  AGENTS_STOLEN BIGINT,  ASSOCIATED_AGENTS_TOP BIGINT,  APPL_PRIORITY BIGINT,  APPL_PRIORITY_TYPE VARCHAR(16),  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  LOCKS_WAITING BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  APPL_IDLE_TIME BIGINT,  UOW_LOCK_WAIT_TIME BIGINT,  UOW_COMP_STATUS VARCHAR(14),  AGENT_USR_CPU_TIME_S BIGINT,  AGENT_USR_CPU_TIME_MS BIGINT,  AGENT_SYS_CPU_TIME_S BIGINT,  AGENT_SYS_CPU_TIME_MS BIGINT,  APPL_CON_TIME TIMESTAMP,  CONN_COMPLETE_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  UOW_START_TIME TIMESTAMP,  UOW_STOP_TIME TIMESTAMP,  PREV_UOW_STOP_TIME TIMESTAMP,  UOW_ELAPSED_TIME_S BIGINT,  UOW_ELAPSED_TIME_MS BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  INBOUND_COMM_ADDRESS VARCHAR(32),  LOCK_TIMEOUT_VAL BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  CAT_CACHE_SIZE_TOP BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  APPL_STATUS VARCHAR(22),  CODEPAGE_ID BIGINT,  NUM_ASSOC_AGENTS BIGINT,  COORD_NODE_NUM SMALLINT,  AUTHORITY_LVL VARCHAR(512),  CLIENT_PID BIGINT,  COORD_AGENT_PID BIGINT,  STATUS_CHANGE_TIME TIMESTAMP,  CLIENT_PLATFORM VARCHAR(12),  CLIENT_PROTOCOL VARCHAR(10),  TERRITORY_CODE SMALLINT,  APPL_NAME VARCHAR(256),  APPL_ID VARCHAR(128),  SEQUENCE_NO VARCHAR(4),  PRIMARY_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  CLIENT_NNAME VARCHAR(128),  CLIENT_PRDID VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  CLIENT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  EXECUTION_ID VARCHAR(128),  CORR_TOKEN VARCHAR(128),  TPMON_CLIENT_USERID VARCHAR(256),  TPMON_CLIENT_WKSTN VARCHAR(256),  TPMON_CLIENT_APP VARCHAR(256),  TPMON_ACC_STR VARCHAR(200),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_INFO_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_info_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  APPL_STATUS VARCHAR(22),  CODEPAGE_ID BIGINT,  NUM_ASSOC_AGENTS BIGINT,  COORD_NODE_NUM SMALLINT,  AUTHORITY_LVL VARCHAR(512),  CLIENT_PID BIGINT,  COORD_AGENT_PID BIGINT,  STATUS_CHANGE_TIME TIMESTAMP,  CLIENT_PLATFORM VARCHAR(12),  CLIENT_PROTOCOL VARCHAR(10),  TERRITORY_CODE SMALLINT,  APPL_NAME VARCHAR(256),  APPL_ID VARCHAR(128),  SEQUENCE_NO VARCHAR(4),  PRIMARY_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  CLIENT_NNAME VARCHAR(128),  CLIENT_PRDID VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  CLIENT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  EXECUTION_ID VARCHAR(128),  CORR_TOKEN VARCHAR(128),  TPMON_CLIENT_USERID VARCHAR(256),  TPMON_CLIENT_WKSTN VARCHAR(256),  TPMON_CLIENT_APP VARCHAR(256),  TPMON_ACC_STR VARCHAR(200),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_INFO"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_info"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO_V95" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  APPL_STATUS VARCHAR(22),  CODEPAGE_ID BIGINT,  NUM_ASSOC_AGENTS BIGINT,  COORD_NODE_NUM SMALLINT,  AUTHORITY_LVL VARCHAR(512),  CLIENT_PID BIGINT,  COORD_AGENT_PID BIGINT,  STATUS_CHANGE_TIME TIMESTAMP,  CLIENT_PLATFORM VARCHAR(12),  CLIENT_PROTOCOL VARCHAR(10),  TERRITORY_CODE SMALLINT,  APPL_NAME VARCHAR(256),  APPL_ID VARCHAR(128),  SEQUENCE_NO VARCHAR(4),  PRIMARY_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  CLIENT_NNAME VARCHAR(128),  CLIENT_PRDID VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  CLIENT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  EXECUTION_ID VARCHAR(128),  CORR_TOKEN VARCHAR(128),  TPMON_CLIENT_USERID VARCHAR(256),  TPMON_CLIENT_WKSTN VARCHAR(256),  TPMON_CLIENT_APP VARCHAR(256),  TPMON_ACC_STR VARCHAR(200),  DBPARTITIONNUM SMALLINT,  WORKLOAD_ID INTEGER,  IS_SYSTEM_APPL SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_INFO_V95_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_info_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO_V95" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  APPL_STATUS VARCHAR(22),  CODEPAGE_ID BIGINT,  NUM_ASSOC_AGENTS BIGINT,  COORD_NODE_NUM SMALLINT,  AUTHORITY_LVL VARCHAR(512),  CLIENT_PID BIGINT,  COORD_AGENT_PID BIGINT,  STATUS_CHANGE_TIME TIMESTAMP,  CLIENT_PLATFORM VARCHAR(12),  CLIENT_PROTOCOL VARCHAR(10),  TERRITORY_CODE SMALLINT,  APPL_NAME VARCHAR(256),  APPL_ID VARCHAR(128),  SEQUENCE_NO VARCHAR(4),  PRIMARY_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  CLIENT_NNAME VARCHAR(128),  CLIENT_PRDID VARCHAR(128),  INPUT_DB_ALIAS VARCHAR(128),  CLIENT_DB_ALIAS VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  EXECUTION_ID VARCHAR(128),  CORR_TOKEN VARCHAR(128),  TPMON_CLIENT_USERID VARCHAR(256),  TPMON_CLIENT_WKSTN VARCHAR(256),  TPMON_CLIENT_APP VARCHAR(256),  TPMON_ACC_STR VARCHAR(200),  DBPARTITIONNUM SMALLINT,  WORKLOAD_ID INTEGER,  IS_SYSTEM_APPL SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_INFO_V95"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_info_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_V95" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  INACT_STMTHIST_SZ BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  DEADLOCKS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  OPEN_REM_CURS BIGINT,  OPEN_REM_CURS_BLK BIGINT,  REJ_CURS_BLK BIGINT,  ACC_CURS_BLK BIGINT,  SQL_REQS_SINCE_COMMIT BIGINT,  LOCK_TIMEOUTS BIGINT,  INT_ROWS_INSERTED BIGINT,  OPEN_LOC_CURS BIGINT,  OPEN_LOC_CURS_BLK BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  NUM_AGENTS BIGINT,  AGENTS_STOLEN BIGINT,  ASSOCIATED_AGENTS_TOP BIGINT,  APPL_PRIORITY BIGINT,  APPL_PRIORITY_TYPE VARCHAR(16),  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  LOCKS_WAITING BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  APPL_IDLE_TIME BIGINT,  UOW_LOCK_WAIT_TIME BIGINT,  UOW_COMP_STATUS VARCHAR(14),  AGENT_USR_CPU_TIME_S BIGINT,  AGENT_USR_CPU_TIME_MS BIGINT,  AGENT_SYS_CPU_TIME_S BIGINT,  AGENT_SYS_CPU_TIME_MS BIGINT,  APPL_CON_TIME TIMESTAMP,  CONN_COMPLETE_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  UOW_START_TIME TIMESTAMP,  UOW_STOP_TIME TIMESTAMP,  PREV_UOW_STOP_TIME TIMESTAMP,  UOW_ELAPSED_TIME_S BIGINT,  UOW_ELAPSED_TIME_MS BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  INBOUND_COMM_ADDRESS VARCHAR(32),  LOCK_TIMEOUT_VAL BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  CAT_CACHE_SIZE_TOP BIGINT,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_V95_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_APPL_V95" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  UOW_LOG_SPACE_USED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  INACT_STMTHIST_SZ BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  DEADLOCKS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  BINDS_PRECOMPILES BIGINT,  OPEN_REM_CURS BIGINT,  OPEN_REM_CURS_BLK BIGINT,  REJ_CURS_BLK BIGINT,  ACC_CURS_BLK BIGINT,  SQL_REQS_SINCE_COMMIT BIGINT,  LOCK_TIMEOUTS BIGINT,  INT_ROWS_INSERTED BIGINT,  OPEN_LOC_CURS BIGINT,  OPEN_LOC_CURS_BLK BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  NUM_AGENTS BIGINT,  AGENTS_STOLEN BIGINT,  ASSOCIATED_AGENTS_TOP BIGINT,  APPL_PRIORITY BIGINT,  APPL_PRIORITY_TYPE VARCHAR(16),  PREFETCH_WAIT_TIME BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  LOCKS_WAITING BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  APPL_IDLE_TIME BIGINT,  UOW_LOCK_WAIT_TIME BIGINT,  UOW_COMP_STATUS VARCHAR(14),  AGENT_USR_CPU_TIME_S BIGINT,  AGENT_USR_CPU_TIME_MS BIGINT,  AGENT_SYS_CPU_TIME_S BIGINT,  AGENT_SYS_CPU_TIME_MS BIGINT,  APPL_CON_TIME TIMESTAMP,  CONN_COMPLETE_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  UOW_START_TIME TIMESTAMP,  UOW_STOP_TIME TIMESTAMP,  PREV_UOW_STOP_TIME TIMESTAMP,  UOW_ELAPSED_TIME_S BIGINT,  UOW_ELAPSED_TIME_MS BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  INBOUND_COMM_ADDRESS VARCHAR(32),  LOCK_TIMEOUT_VAL BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  CAT_CACHE_SIZE_TOP BIGINT,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_APPL_V95"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_appl_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  PHYSICAL_PAGE_MAPS BIGINT,  VECTORED_IOS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  PHYSICAL_PAGE_MAPS BIGINT,  VECTORED_IOS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP_PART" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  BP_CUR_BUFFSZ BIGINT,  BP_NEW_BUFFSZ BIGINT,  BP_PAGES_LEFT_TO_REMOVE BIGINT,  BP_TBSP_USE_COUNT BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP_PART_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp_part_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP_PART" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  BP_CUR_BUFFSZ BIGINT,  BP_NEW_BUFFSZ BIGINT,  BP_PAGES_LEFT_TO_REMOVE BIGINT,  BP_TBSP_USE_COUNT BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP_PART"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp_part"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP_V95" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  VECTORED_IOS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP_V95_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_BP_V95" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BP_NAME VARCHAR(128),  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  FILES_CLOSED BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  PAGES_FROM_BLOCK_IOS BIGINT,  PAGES_FROM_VECTORED_IOS BIGINT,  VECTORED_IOS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_BP_V95"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_bp_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_CONTAINER" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_ID BIGINT,  CONTAINER_TYPE SMALLINT,  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  ACCESSIBLE SMALLINT,  STRIPE_SET BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_CONTAINER"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_container"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_CONTAINER_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_ID BIGINT,  CONTAINER_TYPE VARCHAR(16),  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  ACCESSIBLE SMALLINT,  STRIPE_SET BIGINT,  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_CONTAINER_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_container_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_CONTAINER_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  CONTAINER_NAME VARCHAR(256),  CONTAINER_ID BIGINT,  CONTAINER_TYPE VARCHAR(16),  TOTAL_PAGES BIGINT,  USABLE_PAGES BIGINT,  ACCESSIBLE SMALLINT,  STRIPE_SET BIGINT,  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_CONTAINER_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_container_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS BIGINT,  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM INTEGER,  DB_LOCATION INTEGER,  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_db"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SORT_HEAP_ALLOCATED BIGINT,  POST_THRESHOLD_SORTS BIGINT,  PIPED_SORTS_REQUESTED BIGINT,  PIPED_SORTS_ACCEPTED BIGINT,  REM_CONS_IN BIGINT,  REM_CONS_IN_EXEC BIGINT,  LOCAL_CONS BIGINT,  LOCAL_CONS_IN_EXEC BIGINT,  CON_LOCAL_DBASES BIGINT,  AGENTS_REGISTERED BIGINT,  AGENTS_WAITING_ON_TOKEN BIGINT,  DB2_STATUS VARCHAR(12),  AGENTS_REGISTERED_TOP BIGINT,  AGENTS_WAITING_TOP BIGINT,  COMM_PRIVATE_MEM BIGINT,  IDLE_AGENTS BIGINT,  AGENTS_FROM_POOL BIGINT,  AGENTS_CREATED_EMPTY_POOL BIGINT,  COORD_AGENTS_TOP BIGINT,  MAX_AGENT_OVERFLOWS BIGINT,  AGENTS_STOLEN BIGINT,  GW_TOTAL_CONS BIGINT,  GW_CUR_CONS BIGINT,  GW_CONS_WAIT_HOST BIGINT,  GW_CONS_WAIT_CLIENT BIGINT,  POST_THRESHOLD_HASH_JOINS BIGINT,  NUM_GW_CONN_SWITCHES BIGINT,  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  NUM_NODES_IN_DB2_INSTANCE INTEGER,  PRODUCT_NAME VARCHAR(32),  SERVICE_LEVEL VARCHAR(18),  SORT_HEAP_TOP BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SORT_HEAP_ALLOCATED BIGINT,  POST_THRESHOLD_SORTS BIGINT,  PIPED_SORTS_REQUESTED BIGINT,  PIPED_SORTS_ACCEPTED BIGINT,  REM_CONS_IN BIGINT,  REM_CONS_IN_EXEC BIGINT,  LOCAL_CONS BIGINT,  LOCAL_CONS_IN_EXEC BIGINT,  CON_LOCAL_DBASES BIGINT,  AGENTS_REGISTERED BIGINT,  AGENTS_WAITING_ON_TOKEN BIGINT,  DB2_STATUS VARCHAR(12),  AGENTS_REGISTERED_TOP BIGINT,  AGENTS_WAITING_TOP BIGINT,  COMM_PRIVATE_MEM BIGINT,  IDLE_AGENTS BIGINT,  AGENTS_FROM_POOL BIGINT,  AGENTS_CREATED_EMPTY_POOL BIGINT,  COORD_AGENTS_TOP BIGINT,  MAX_AGENT_OVERFLOWS BIGINT,  AGENTS_STOLEN BIGINT,  GW_TOTAL_CONS BIGINT,  GW_CUR_CONS BIGINT,  GW_CONS_WAIT_HOST BIGINT,  GW_CONS_WAIT_CLIENT BIGINT,  POST_THRESHOLD_HASH_JOINS BIGINT,  NUM_GW_CONN_SWITCHES BIGINT,  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  NUM_NODES_IN_DB2_INSTANCE INTEGER,  PRODUCT_NAME VARCHAR(32),  SERVICE_LEVEL VARCHAR(18),  SORT_HEAP_TOP BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  POOL_ID VARCHAR(14),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm_memory_pool_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  POOL_ID VARCHAR(14),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm_memory_pool"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM_V95" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SORT_HEAP_ALLOCATED BIGINT,  POST_THRESHOLD_SORTS BIGINT,  PIPED_SORTS_REQUESTED BIGINT,  PIPED_SORTS_ACCEPTED BIGINT,  REM_CONS_IN BIGINT,  REM_CONS_IN_EXEC BIGINT,  LOCAL_CONS BIGINT,  LOCAL_CONS_IN_EXEC BIGINT,  CON_LOCAL_DBASES BIGINT,  AGENTS_REGISTERED BIGINT,  AGENTS_WAITING_ON_TOKEN BIGINT,  DB2_STATUS VARCHAR(12),  AGENTS_REGISTERED_TOP BIGINT,  AGENTS_WAITING_TOP BIGINT,  COMM_PRIVATE_MEM BIGINT,  IDLE_AGENTS BIGINT,  AGENTS_FROM_POOL BIGINT,  AGENTS_CREATED_EMPTY_POOL BIGINT,  COORD_AGENTS_TOP BIGINT,  MAX_AGENT_OVERFLOWS BIGINT,  AGENTS_STOLEN BIGINT,  GW_TOTAL_CONS BIGINT,  GW_CUR_CONS BIGINT,  GW_CONS_WAIT_HOST BIGINT,  GW_CONS_WAIT_CLIENT BIGINT,  POST_THRESHOLD_HASH_JOINS BIGINT,  NUM_GW_CONN_SWITCHES BIGINT,  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  NUM_NODES_IN_DB2_INSTANCE INTEGER,  PRODUCT_NAME VARCHAR(32),  SERVICE_LEVEL VARCHAR(18),  SORT_HEAP_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  POST_THRESHOLD_OLAP_FUNCS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM_V95_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DBM_V95" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  SORT_HEAP_ALLOCATED BIGINT,  POST_THRESHOLD_SORTS BIGINT,  PIPED_SORTS_REQUESTED BIGINT,  PIPED_SORTS_ACCEPTED BIGINT,  REM_CONS_IN BIGINT,  REM_CONS_IN_EXEC BIGINT,  LOCAL_CONS BIGINT,  LOCAL_CONS_IN_EXEC BIGINT,  CON_LOCAL_DBASES BIGINT,  AGENTS_REGISTERED BIGINT,  AGENTS_WAITING_ON_TOKEN BIGINT,  DB2_STATUS VARCHAR(12),  AGENTS_REGISTERED_TOP BIGINT,  AGENTS_WAITING_TOP BIGINT,  COMM_PRIVATE_MEM BIGINT,  IDLE_AGENTS BIGINT,  AGENTS_FROM_POOL BIGINT,  AGENTS_CREATED_EMPTY_POOL BIGINT,  COORD_AGENTS_TOP BIGINT,  MAX_AGENT_OVERFLOWS BIGINT,  AGENTS_STOLEN BIGINT,  GW_TOTAL_CONS BIGINT,  GW_CUR_CONS BIGINT,  GW_CONS_WAIT_HOST BIGINT,  GW_CONS_WAIT_CLIENT BIGINT,  POST_THRESHOLD_HASH_JOINS BIGINT,  NUM_GW_CONN_SWITCHES BIGINT,  DB2START_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  NUM_NODES_IN_DB2_INSTANCE INTEGER,  PRODUCT_NAME VARCHAR(32),  SERVICE_LEVEL VARCHAR(18),  SORT_HEAP_TOP BIGINT,  DBPARTITIONNUM SMALLINT,  POST_THRESHOLD_OLAP_FUNCS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DBM_V95"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dbm_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_MEMORY_POOL" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  POOL_ID VARCHAR(14),  POOL_SECONDARY_ID VARCHAR(32),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_MEMORY_POOL_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_memory_pool_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_MEMORY_POOL" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  POOL_ID VARCHAR(14),  POOL_SECONDARY_ID VARCHAR(32),  POOL_CUR_SIZE BIGINT,  POOL_WATERMARK BIGINT,  POOL_CONFIG_SIZE BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_MEMORY_POOL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_memory_pool"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(12),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V91_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(12),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V91"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V95" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(12),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT,  ACTIVE_OLAP_FUNCS BIGINT,  STATS_CACHE_SIZE BIGINT,  STATS_FABRICATIONS BIGINT,  SYNC_RUNSTATS BIGINT,  ASYNC_RUNSTATS BIGINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT,  NUM_THRESHOLD_VIOLATIONS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V95_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V95" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(12),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT,  ACTIVE_OLAP_FUNCS BIGINT,  STATS_CACHE_SIZE BIGINT,  STATS_FABRICATIONS BIGINT,  SYNC_RUNSTATS BIGINT,  ASYNC_RUNSTATS BIGINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT,  NUM_THRESHOLD_VIOLATIONS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V95"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V97" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(16),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT,  ACTIVE_OLAP_FUNCS BIGINT,  STATS_CACHE_SIZE BIGINT,  STATS_FABRICATIONS BIGINT,  SYNC_RUNSTATS BIGINT,  ASYNC_RUNSTATS BIGINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT,  NUM_THRESHOLD_VIOLATIONS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V97_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v97_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DB_V97" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_PATH VARCHAR(1024),  INPUT_DB_ALIAS VARCHAR(128),  DB_STATUS VARCHAR(16),  CATALOG_PARTITION SMALLINT,  CATALOG_PARTITION_NAME VARCHAR(128),  SERVER_PLATFORM VARCHAR(12),  DB_LOCATION VARCHAR(12),  DB_CONN_TIME TIMESTAMP,  LAST_RESET TIMESTAMP,  LAST_BACKUP TIMESTAMP,  CONNECTIONS_TOP BIGINT,  TOTAL_CONS BIGINT,  TOTAL_SEC_CONS BIGINT,  APPLS_CUR_CONS BIGINT,  APPLS_IN_DB2 BIGINT,  NUM_ASSOC_AGENTS BIGINT,  AGENTS_TOP BIGINT,  COORD_AGENTS_TOP BIGINT,  LOCKS_HELD BIGINT,  LOCK_WAITS BIGINT,  LOCK_WAIT_TIME BIGINT,  LOCK_LIST_IN_USE BIGINT,  DEADLOCKS BIGINT,  LOCK_ESCALS BIGINT,  X_LOCK_ESCALS BIGINT,  LOCKS_WAITING BIGINT,  LOCK_TIMEOUTS BIGINT,  NUM_INDOUBT_TRANS BIGINT,  SORT_HEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_ALLOCATED BIGINT,  SORT_SHRHEAP_TOP BIGINT,  POST_SHRTHRESHOLD_SORTS BIGINT,  TOTAL_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  ACTIVE_SORTS BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  POOL_LSN_GAP_CLNS BIGINT,  POOL_DRTY_PG_STEAL_CLNS BIGINT,  POOL_DRTY_PG_THRSH_CLNS BIGINT,  PREFETCH_WAIT_TIME BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  ELAPSED_EXEC_TIME_S BIGINT,  ELAPSED_EXEC_TIME_MS BIGINT,  COMMIT_SQL_STMTS BIGINT,  ROLLBACK_SQL_STMTS BIGINT,  DYNAMIC_SQL_STMTS BIGINT,  STATIC_SQL_STMTS BIGINT,  FAILED_SQL_STMTS BIGINT,  SELECT_SQL_STMTS BIGINT,  UID_SQL_STMTS BIGINT,  DDL_SQL_STMTS BIGINT,  INT_AUTO_REBINDS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_COMMITS BIGINT,  INT_ROLLBACKS BIGINT,  INT_DEADLOCK_ROLLBACKS BIGINT,  ROWS_DELETED BIGINT,  ROWS_INSERTED BIGINT,  ROWS_UPDATED BIGINT,  ROWS_SELECTED BIGINT,  ROWS_READ BIGINT,  BINDS_PRECOMPILES BIGINT,  TOTAL_LOG_AVAILABLE BIGINT,  TOTAL_LOG_USED BIGINT,  SEC_LOG_USED_TOP BIGINT,  TOT_LOG_USED_TOP BIGINT,  SEC_LOGS_ALLOCATED BIGINT,  LOG_READS BIGINT,  LOG_READ_TIME_S BIGINT,  LOG_READ_TIME_NS BIGINT,  LOG_WRITES BIGINT,  LOG_WRITE_TIME_S BIGINT,  LOG_WRITE_TIME_NS BIGINT,  NUM_LOG_WRITE_IO BIGINT,  NUM_LOG_READ_IO BIGINT,  NUM_LOG_PART_PAGE_IO BIGINT,  NUM_LOG_BUFFER_FULL BIGINT,  NUM_LOG_DATA_FOUND_IN_BUFFER BIGINT,  APPL_ID_OLDEST_XACT BIGINT,  LOG_TO_REDO_FOR_RECOVERY BIGINT,  LOG_HELD_BY_DIRTY_PAGES BIGINT,  PKG_CACHE_LOOKUPS BIGINT,  PKG_CACHE_INSERTS BIGINT,  PKG_CACHE_NUM_OVERFLOWS BIGINT,  PKG_CACHE_SIZE_TOP BIGINT,  APPL_SECTION_LOOKUPS BIGINT,  APPL_SECTION_INSERTS BIGINT,  CAT_CACHE_LOOKUPS BIGINT,  CAT_CACHE_INSERTS BIGINT,  CAT_CACHE_OVERFLOWS BIGINT,  CAT_CACHE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_SIZE_TOP BIGINT,  PRIV_WORKSPACE_NUM_OVERFLOWS BIGINT,  PRIV_WORKSPACE_SECTION_INSERTS BIGINT,  PRIV_WORKSPACE_SECTION_LOOKUPS BIGINT,  SHR_WORKSPACE_SIZE_TOP BIGINT,  SHR_WORKSPACE_NUM_OVERFLOWS BIGINT,  SHR_WORKSPACE_SECTION_INSERTS BIGINT,  SHR_WORKSPACE_SECTION_LOOKUPS BIGINT,  TOTAL_HASH_JOINS BIGINT,  TOTAL_HASH_LOOPS BIGINT,  HASH_JOIN_OVERFLOWS BIGINT,  HASH_JOIN_SMALL_OVERFLOWS BIGINT,  POST_SHRTHRESHOLD_HASH_JOINS BIGINT,  ACTIVE_HASH_JOINS BIGINT,  NUM_DB_STORAGE_PATHS BIGINT,  DBPARTITIONNUM SMALLINT,  SMALLEST_LOG_AVAIL_NODE INTEGER,  TOTAL_OLAP_FUNCS BIGINT,  OLAP_FUNC_OVERFLOWS BIGINT,  ACTIVE_OLAP_FUNCS BIGINT,  STATS_CACHE_SIZE BIGINT,  STATS_FABRICATIONS BIGINT,  SYNC_RUNSTATS BIGINT,  ASYNC_RUNSTATS BIGINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT,  NUM_THRESHOLD_VIOLATIONS BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DB_V97"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_db_v97"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  FIRST_ACTIVE_LOG BIGINT,  LAST_ACTIVE_LOG BIGINT,  CURRENT_ACTIVE_LOG BIGINT,  CURRENT_ARCHIVE_LOG BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DETAILLOG"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_detaillog"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  FIRST_ACTIVE_LOG BIGINT,  LAST_ACTIVE_LOG BIGINT,  CURRENT_ACTIVE_LOG BIGINT,  CURRENT_ARCHIVE_LOG BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DETAILLOG_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_detaillog_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  FIRST_ACTIVE_LOG BIGINT,  LAST_ACTIVE_LOG BIGINT,  CURRENT_ACTIVE_LOG BIGINT,  CURRENT_ARCHIVE_LOG BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DETAILLOG_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_detaillog"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  STMT_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_SORT_TIME BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_EXEC_TIME_MS BIGINT,  TOTAL_USR_TIME BIGINT,  TOTAL_USR_TIME_MS BIGINT,  TOTAL_SYS_TIME BIGINT,  TOTAL_SYS_TIME_MS BIGINT,  STMT_TEXT CLOB(1048576))
	SPECIFIC "SYSPROC"."SNAP_GET_DYN_SQL"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_dyn_sql"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  STMT_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_SORT_TIME BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_EXEC_TIME_MS BIGINT,  TOTAL_USR_CPU_TIME BIGINT,  TOTAL_USR_CPU_TIME_MS BIGINT,  TOTAL_SYS_CPU_TIME BIGINT,  TOTAL_SYS_CPU_TIME_MS BIGINT,  STMT_TEXT CLOB(2097152),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DYN_SQL_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dyn_sql_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  STMT_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_SORT_TIME BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_EXEC_TIME_MS BIGINT,  TOTAL_USR_CPU_TIME BIGINT,  TOTAL_USR_CPU_TIME_MS BIGINT,  TOTAL_SYS_CPU_TIME BIGINT,  TOTAL_SYS_CPU_TIME_MS BIGINT,  STMT_TEXT CLOB(2097152),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DYN_SQL_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dyn_sql_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V95" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  STMT_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_SORT_TIME BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_EXEC_TIME_MS BIGINT,  TOTAL_USR_CPU_TIME BIGINT,  TOTAL_USR_CPU_TIME_MS BIGINT,  TOTAL_SYS_CPU_TIME BIGINT,  TOTAL_SYS_CPU_TIME_MS BIGINT,  STMT_TEXT CLOB(2097152),  DBPARTITIONNUM SMALLINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DYN_SQL_V95_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dyn_sql_v95_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V95" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  NUM_EXECUTIONS BIGINT,  NUM_COMPILATIONS BIGINT,  PREP_TIME_WORST BIGINT,  PREP_TIME_BEST BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_INSERTED BIGINT,  INT_ROWS_UPDATED BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  STMT_SORTS BIGINT,  SORT_OVERFLOWS BIGINT,  TOTAL_SORT_TIME BIGINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  TOTAL_EXEC_TIME BIGINT,  TOTAL_EXEC_TIME_MS BIGINT,  TOTAL_USR_CPU_TIME BIGINT,  TOTAL_USR_CPU_TIME_MS BIGINT,  TOTAL_SYS_CPU_TIME BIGINT,  TOTAL_SYS_CPU_TIME_MS BIGINT,  STMT_TEXT CLOB(2097152),  DBPARTITIONNUM SMALLINT,  STATS_FABRICATE_TIME BIGINT,  SYNC_RUNSTATS_TIME BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_DYN_SQL_V95"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_dyn_sql_v95"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_FCM" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BUFF_FREE BIGINT,  BUFF_FREE_BOTTOM BIGINT,  CH_FREE BIGINT,  CH_FREE_BOTTOM BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_FCM_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_fcm_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_FCM" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  BUFF_FREE BIGINT,  BUFF_FREE_BOTTOM BIGINT,  CH_FREE BIGINT,  CH_FREE_BOTTOM BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_FCM"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_fcm"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_FCM_PART" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONNECTION_STATUS VARCHAR(10),  TOTAL_BUFFERS_SENT BIGINT,  TOTAL_BUFFERS_RCVD BIGINT,  DBPARTITIONNUM SMALLINT,  FCM_DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_FCM_PART_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_fcm_part_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_FCM_PART" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  CONNECTION_STATUS VARCHAR(10),  TOTAL_BUFFERS_SENT BIGINT,  TOTAL_BUFFERS_RCVD BIGINT,  DBPARTITIONNUM SMALLINT,  FCM_DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_FCM_PART"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_fcm_part"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_HADR" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  HADR_ROLE VARCHAR(10),  HADR_STATE VARCHAR(14),  HADR_SYNCMODE VARCHAR(10),  HADR_CONNECT_STATUS VARCHAR(12),  HADR_CONNECT_TIME TIMESTAMP,  HADR_HEARTBEAT INTEGER,  HADR_LOCAL_HOST VARCHAR(255),  HADR_LOCAL_SERVICE VARCHAR(40),  HADR_REMOTE_HOST VARCHAR(255),  HADR_REMOTE_SERVICE VARCHAR(40),  HADR_REMOTE_INSTANCE VARCHAR(128),  HADR_TIMEOUT BIGINT,  HADR_PRIMARY_LOG_FILE VARCHAR(255),  HADR_PRIMARY_LOG_PAGE BIGINT,  HADR_PRIMARY_LOG_LSN BIGINT,  HADR_STANDBY_LOG_FILE VARCHAR(255),  HADR_STANDBY_LOG_PAGE BIGINT,  HADR_STANDBY_LOG_LSN BIGINT,  HADR_LOG_GAP BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_HADR_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_hadr_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_HADR" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  HADR_ROLE VARCHAR(10),  HADR_STATE VARCHAR(14),  HADR_SYNCMODE VARCHAR(10),  HADR_CONNECT_STATUS VARCHAR(12),  HADR_CONNECT_TIME TIMESTAMP,  HADR_HEARTBEAT INTEGER,  HADR_LOCAL_HOST VARCHAR(255),  HADR_LOCAL_SERVICE VARCHAR(40),  HADR_REMOTE_HOST VARCHAR(255),  HADR_REMOTE_SERVICE VARCHAR(40),  HADR_REMOTE_INSTANCE VARCHAR(128),  HADR_TIMEOUT BIGINT,  HADR_PRIMARY_LOG_FILE VARCHAR(255),  HADR_PRIMARY_LOG_PAGE BIGINT,  HADR_PRIMARY_LOG_LSN BIGINT,  HADR_STANDBY_LOG_FILE VARCHAR(255),  HADR_STANDBY_LOG_PAGE BIGINT,  HADR_STANDBY_LOG_LSN BIGINT,  HADR_LOG_GAP BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_HADR"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_hadr"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_LOCK" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  TAB_FILE_ID BIGINT,  LOCK_OBJECT_TYPE VARCHAR(18),  LOCK_MODE VARCHAR(10),  LOCK_STATUS VARCHAR(10),  LOCK_ESCALATION SMALLINT,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TBSP_NAME VARCHAR(128),  LOCK_ATTRIBUTES VARCHAR(128),  LOCK_COUNT BIGINT,  LOCK_CURRENT_MODE VARCHAR(10),  LOCK_HOLD_COUNT BIGINT,  LOCK_NAME VARCHAR(32),  LOCK_RELEASE_FLAGS BIGINT,  DATA_PARTITION_ID INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_LOCK_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_lock_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_LOCK" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  TAB_FILE_ID BIGINT,  LOCK_OBJECT_TYPE VARCHAR(18),  LOCK_MODE VARCHAR(10),  LOCK_STATUS VARCHAR(10),  LOCK_ESCALATION SMALLINT,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TBSP_NAME VARCHAR(128),  LOCK_ATTRIBUTES VARCHAR(128),  LOCK_COUNT BIGINT,  LOCK_CURRENT_MODE VARCHAR(10),  LOCK_HOLD_COUNT BIGINT,  LOCK_NAME VARCHAR(32),  LOCK_RELEASE_FLAGS BIGINT,  DATA_PARTITION_ID INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_LOCK"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_lock"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_LOCKWAIT" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  SUBSECTION_NUMBER BIGINT,  LOCK_MODE VARCHAR(10),  LOCK_OBJECT_TYPE VARCHAR(18),  AGENT_ID_HOLDING_LK BIGINT,  LOCK_WAIT_START_TIME TIMESTAMP,  LOCK_MODE_REQUESTED VARCHAR(10),  LOCK_ESCALATION SMALLINT,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TBSP_NAME VARCHAR(128),  APPL_ID_HOLDING_LK VARCHAR(128),  LOCK_ATTRIBUTES VARCHAR(128),  LOCK_CURRENT_MODE VARCHAR(10),  LOCK_NAME VARCHAR(32),  LOCK_RELEASE_FLAGS BIGINT,  DATA_PARTITION_ID INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_LOCKWAIT_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_lockwait_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_LOCKWAIT" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  AGENT_ID BIGINT,  SUBSECTION_NUMBER BIGINT,  LOCK_MODE VARCHAR(10),  LOCK_OBJECT_TYPE VARCHAR(18),  AGENT_ID_HOLDING_LK BIGINT,  LOCK_WAIT_START_TIME TIMESTAMP,  LOCK_MODE_REQUESTED VARCHAR(10),  LOCK_ESCALATION SMALLINT,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  TBSP_NAME VARCHAR(128),  APPL_ID_HOLDING_LK VARCHAR(128),  LOCK_ATTRIBUTES VARCHAR(128),  LOCK_CURRENT_MODE VARCHAR(10),  LOCK_NAME VARCHAR(32),  LOCK_RELEASE_FLAGS BIGINT,  DATA_PARTITION_ID INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_LOCKWAIT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_lockwait"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STMT" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  NUM_AGENTS BIGINT,  AGENTS_TOP BIGINT,  STMT_TYPE VARCHAR(20),  STMT_OPERATION VARCHAR(20),  SECTION_NUMBER BIGINT,  QUERY_COST_ESTIMATE BIGINT,  QUERY_CARD_ESTIMATE BIGINT,  DEGREE_PARALLELISM BIGINT,  STMT_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_ROWS_INSERTED BIGINT,  FETCH_COUNT BIGINT,  STMT_START TIMESTAMP,  STMT_STOP TIMESTAMP,  STMT_USR_CPU_TIME_S BIGINT,  STMT_USR_CPU_TIME_MS BIGINT,  STMT_SYS_CPU_TIME_S BIGINT,  STMT_SYS_CPU_TIME_MS BIGINT,  STMT_ELAPSED_TIME_S BIGINT,  STMT_ELAPSED_TIME_MS BIGINT,  BLOCKING_CURSOR SMALLINT,  STMT_NODE_NUMBER SMALLINT,  CURSOR_NAME VARCHAR(128),  CREATOR VARCHAR(128),  PACKAGE_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216),  CONSISTENCY_TOKEN VARCHAR(128),  PACKAGE_VERSION_ID VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_STMT_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_stmt_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STMT" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  AGENT_ID BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  NUM_AGENTS BIGINT,  AGENTS_TOP BIGINT,  STMT_TYPE VARCHAR(20),  STMT_OPERATION VARCHAR(20),  SECTION_NUMBER BIGINT,  QUERY_COST_ESTIMATE BIGINT,  QUERY_CARD_ESTIMATE BIGINT,  DEGREE_PARALLELISM BIGINT,  STMT_SORTS BIGINT,  TOTAL_SORT_TIME BIGINT,  SORT_OVERFLOWS BIGINT,  INT_ROWS_DELETED BIGINT,  INT_ROWS_UPDATED BIGINT,  INT_ROWS_INSERTED BIGINT,  FETCH_COUNT BIGINT,  STMT_START TIMESTAMP,  STMT_STOP TIMESTAMP,  STMT_USR_CPU_TIME_S BIGINT,  STMT_USR_CPU_TIME_MS BIGINT,  STMT_SYS_CPU_TIME_S BIGINT,  STMT_SYS_CPU_TIME_MS BIGINT,  STMT_ELAPSED_TIME_S BIGINT,  STMT_ELAPSED_TIME_MS BIGINT,  BLOCKING_CURSOR SMALLINT,  STMT_NODE_NUMBER SMALLINT,  CURSOR_NAME VARCHAR(128),  CREATOR VARCHAR(128),  PACKAGE_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216),  CONSISTENCY_TOKEN VARCHAR(128),  PACKAGE_VERSION_ID VARCHAR(128),  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_STMT"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_stmt"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_STORAGE_PATH VARCHAR(256),  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT,  STO_PATH_FREE_SIZE BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_STORAGE_PATHS_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_sto_paths_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_STORAGE_PATH VARCHAR(256),  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT,  STO_PATH_FREE_SIZE BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_STORAGE_PATHS"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_sto_paths_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_STORAGE_PATH VARCHAR(256),  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT,  STO_PATH_FREE_SIZE BIGINT,  DB_STORAGE_PATH_WITH_DPE VARCHAR(256),  DB_STORAGE_PATH_STATE VARCHAR(16))
	SPECIFIC "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_sto_paths_v97_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_STORAGE_PATH VARCHAR(256),  DBPARTITIONNUM SMALLINT,  FS_ID VARCHAR(22),  FS_TOTAL_SIZE BIGINT,  FS_USED_SIZE BIGINT,  STO_PATH_FREE_SIZE BIGINT,  DB_STORAGE_PATH_WITH_DPE VARCHAR(256),  DB_STORAGE_PATH_STATE VARCHAR(16))
	SPECIFIC "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_sto_paths_v97"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_STO_PATHS" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  DB_STORAGE_PATH VARCHAR(256))
	SPECIFIC "SYSPROC"."SNAP_GET_STO_PATHS"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_sto_paths"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_SUBSECTION" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216),  SS_EXEC_TIME BIGINT,  TQ_TOT_SEND_SPILLS BIGINT,  TQ_CUR_SEND_SPILLS BIGINT,  TQ_MAX_SEND_SPILLS BIGINT,  TQ_ROWS_READ BIGINT,  TQ_ROWS_WRITTEN BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  SS_USR_CPU_TIME_S BIGINT,  SS_USR_CPU_TIME_MS BIGINT,  SS_SYS_CPU_TIME_S BIGINT,  SS_SYS_CPU_TIME_MS BIGINT,  SS_NUMBER INTEGER,  SS_STATUS VARCHAR(20),  SS_NODE_NUMBER SMALLINT,  TQ_NODE_WAITED_FOR SMALLINT,  TQ_WAIT_FOR_ANY INTEGER,  TQ_ID_WAITING_ON INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_SUBSECTION_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_subsection_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_SUBSECTION" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  DB_NAME VARCHAR(128),  STMT_TEXT CLOB(16777216),  SS_EXEC_TIME BIGINT,  TQ_TOT_SEND_SPILLS BIGINT,  TQ_CUR_SEND_SPILLS BIGINT,  TQ_MAX_SEND_SPILLS BIGINT,  TQ_ROWS_READ BIGINT,  TQ_ROWS_WRITTEN BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  SS_USR_CPU_TIME_S BIGINT,  SS_USR_CPU_TIME_MS BIGINT,  SS_SYS_CPU_TIME_S BIGINT,  SS_SYS_CPU_TIME_MS BIGINT,  SS_NUMBER INTEGER,  SS_STATUS VARCHAR(20),  SS_NODE_NUMBER SMALLINT,  TQ_NODE_WAITED_FOR SMALLINT,  TQ_WAIT_FOR_ANY INTEGER,  TQ_ID_WAITING_ON INTEGER,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_SUBSECTION"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_subsection"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_SWITCHES" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UOW_SW_STATE SMALLINT,  UOW_SW_TIME TIMESTAMP,  STATEMENT_SW_STATE SMALLINT,  STATEMENT_SW_TIME TIMESTAMP,  TABLE_SW_STATE SMALLINT,  TABLE_SW_TIME TIMESTAMP,  BUFFPOOL_SW_STATE SMALLINT,  BUFFPOOL_SW_TIME TIMESTAMP,  LOCK_SW_STATE SMALLINT,  LOCK_SW_TIME TIMESTAMP,  SORT_SW_STATE SMALLINT,  SORT_SW_TIME TIMESTAMP,  TIMESTAMP_SW_STATE SMALLINT,  TIMESTAMP_SW_TIME TIMESTAMP,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_SWITCHES_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_switches_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_SWITCHES" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UOW_SW_STATE SMALLINT,  UOW_SW_TIME TIMESTAMP,  STATEMENT_SW_STATE SMALLINT,  STATEMENT_SW_TIME TIMESTAMP,  TABLE_SW_STATE SMALLINT,  TABLE_SW_TIME TIMESTAMP,  BUFFPOOL_SW_STATE SMALLINT,  BUFFPOOL_SW_TIME TIMESTAMP,  LOCK_SW_STATE SMALLINT,  LOCK_SW_TIME TIMESTAMP,  SORT_SW_STATE SMALLINT,  SORT_SW_TIME TIMESTAMP,  TIMESTAMP_SW_STATE SMALLINT,  TIMESTAMP_SW_TIME TIMESTAMP,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_SWITCHES"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_switches"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TAB" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TAB_FILE_ID BIGINT,  TAB_TYPE BIGINT,  DATA_OBJECT_PAGES BIGINT,  INDEX_OBJECT_PAGES BIGINT,  LOB_OBJECT_PAGES BIGINT,  LONG_OBJECT_PAGES BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  OVERFLOW_ACCESSES BIGINT,  PAGE_REORGS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TAB"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_tab"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TAB_REORG" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  PAGE_REORGS BIGINT,  REORG_PHASE VARCHAR(16),  REORG_MAX_PHASE INTEGER,  REORG_CURRENT_COUNTER BIGINT,  REORG_MAX_COUNTER BIGINT,  REORG_TYPE VARCHAR(128),  REORG_STATUS VARCHAR(10),  REORG_COMPLETION VARCHAR(10),  REORG_START TIMESTAMP,  REORG_END TIMESTAMP,  REORG_PHASE_START TIMESTAMP,  REORG_INDEX_ID BIGINT,  REORG_TBSPC_ID BIGINT,  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  REORG_ROWSCOMPRESSED BIGINT,  REORG_ROWSREJECTED BIGINT,  REORG_LONG_TBSPC_ID BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TAB_REORG_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tab_reorg_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TAB_REORG" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABNAME VARCHAR(128),  TABSCHEMA VARCHAR(128),  PAGE_REORGS BIGINT,  REORG_PHASE VARCHAR(16),  REORG_MAX_PHASE INTEGER,  REORG_CURRENT_COUNTER BIGINT,  REORG_MAX_COUNTER BIGINT,  REORG_TYPE VARCHAR(128),  REORG_STATUS VARCHAR(10),  REORG_COMPLETION VARCHAR(10),  REORG_START TIMESTAMP,  REORG_END TIMESTAMP,  REORG_PHASE_START TIMESTAMP,  REORG_INDEX_ID BIGINT,  REORG_TBSPC_ID BIGINT,  DBPARTITIONNUM SMALLINT,  DATA_PARTITION_ID INTEGER,  REORG_ROWSCOMPRESSED BIGINT,  REORG_ROWSREJECTED BIGINT,  REORG_LONG_TBSPC_ID BIGINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TAB_REORG"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tab_reorg"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TAB_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TAB_FILE_ID BIGINT,  TAB_TYPE VARCHAR(14),  DATA_OBJECT_PAGES BIGINT,  INDEX_OBJECT_PAGES BIGINT,  LOB_OBJECT_PAGES BIGINT,  LONG_OBJECT_PAGES BIGINT,  XDA_OBJECT_PAGES BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  OVERFLOW_ACCESSES BIGINT,  PAGE_REORGS BIGINT,  DBPARTITIONNUM SMALLINT,  TBSP_ID BIGINT,  DATA_PARTITION_ID INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_TAB_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tab_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TAB_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TABSCHEMA VARCHAR(128),  TABNAME VARCHAR(128),  TAB_FILE_ID BIGINT,  TAB_TYPE VARCHAR(14),  DATA_OBJECT_PAGES BIGINT,  INDEX_OBJECT_PAGES BIGINT,  LOB_OBJECT_PAGES BIGINT,  LONG_OBJECT_PAGES BIGINT,  XDA_OBJECT_PAGES BIGINT,  ROWS_READ BIGINT,  ROWS_WRITTEN BIGINT,  OVERFLOW_ACCESSES BIGINT,  PAGE_REORGS BIGINT,  DBPARTITIONNUM SMALLINT,  TBSP_ID BIGINT,  DATA_PARTITION_ID INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_TAB_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tab_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_TYPE SMALLINT,  TBSP_CONTENT_TYPE SMALLINT,  TBSP_PAGE_SIZE BIGINT,  TBSP_EXTENT_SIZE BIGINT,  TBSP_PREFETCH_SIZE BIGINT,  TBSP_CUR_POOL_ID BIGINT,  TBSP_NEXT_POOL_ID BIGINT,  FS_CACHING SMALLINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  POOL_DATA_TO_ESTORE BIGINT,  POOL_INDEX_TO_ESTORE BIGINT,  POOL_INDEX_FROM_ESTORE BIGINT,  POOL_DATA_FROM_ESTORE BIGINT,  TBSP_REBALANCER_MODE BIGINT,  TBSP_USING_AUTO_STORAGE SMALLINT,  TBSP_AUTO_RESIZE_ENABLED SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_tbsp"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART" (VARCHAR(255), 
		INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_STATE BIGINT,  TBSP_PREFETCH_SIZE BIGINT,  TBSP_NUM_QUIESCERS BIGINT,  TBSP_STATE_CHANGE_OBJECT_ID BIGINT,  TBSP_STATE_CHANGE_TBSP_ID BIGINT,  TBSP_MIN_RECOVERY_TIME TIMESTAMP,  TBSP_TOTAL_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  REBALANCER_MODE BIGINT,  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  REBALANCER_LAST_EXTENT_MOVED BIGINT,  TBSP_NUM_RANGES BIGINT,  TBSP_NUM_CONTAINERS BIGINT,  TBSP_INITIAL_SIZE BIGINT,  TBSP_CURRENT_SIZE BIGINT,  TBSP_MAX_SIZE BIGINT,  TBSP_INCREASE_SIZE BIGINT,  TBSP_INCREASE_SIZE_PERCENT SMALLINT,  TBSP_LAST_RESIZE_TIME TIMESTAMP,  TBSP_LAST_RESIZE_FAILED SMALLINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_PART"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!snap_get_tbsp_part"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_STATE VARCHAR(256),  TBSP_PREFETCH_SIZE BIGINT,  TBSP_NUM_QUIESCERS BIGINT,  TBSP_STATE_CHANGE_OBJECT_ID BIGINT,  TBSP_STATE_CHANGE_TBSP_ID BIGINT,  TBSP_MIN_RECOVERY_TIME TIMESTAMP,  TBSP_TOTAL_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  REBALANCER_MODE VARCHAR(10),  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  REBALANCER_LAST_EXTENT_MOVED BIGINT,  TBSP_NUM_RANGES BIGINT,  TBSP_NUM_CONTAINERS BIGINT,  TBSP_INITIAL_SIZE BIGINT,  TBSP_CURRENT_SIZE BIGINT,  TBSP_MAX_SIZE BIGINT,  TBSP_INCREASE_SIZE BIGINT,  TBSP_INCREASE_SIZE_PERCENT SMALLINT,  TBSP_LAST_RESIZE_TIME TIMESTAMP,  TBSP_LAST_RESIZE_FAILED SMALLINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_PART_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_part_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_STATE VARCHAR(256),  TBSP_PREFETCH_SIZE BIGINT,  TBSP_NUM_QUIESCERS BIGINT,  TBSP_STATE_CHANGE_OBJECT_ID BIGINT,  TBSP_STATE_CHANGE_TBSP_ID BIGINT,  TBSP_MIN_RECOVERY_TIME TIMESTAMP,  TBSP_TOTAL_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  REBALANCER_MODE VARCHAR(10),  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  REBALANCER_LAST_EXTENT_MOVED BIGINT,  TBSP_NUM_RANGES BIGINT,  TBSP_NUM_CONTAINERS BIGINT,  TBSP_INITIAL_SIZE BIGINT,  TBSP_CURRENT_SIZE BIGINT,  TBSP_MAX_SIZE BIGINT,  TBSP_INCREASE_SIZE BIGINT,  TBSP_INCREASE_SIZE_PERCENT SMALLINT,  TBSP_LAST_RESIZE_TIME TIMESTAMP,  TBSP_LAST_RESIZE_FAILED SMALLINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_PART_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_part_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V97" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_STATE VARCHAR(256),  TBSP_PREFETCH_SIZE BIGINT,  TBSP_NUM_QUIESCERS BIGINT,  TBSP_STATE_CHANGE_OBJECT_ID BIGINT,  TBSP_STATE_CHANGE_TBSP_ID BIGINT,  TBSP_MIN_RECOVERY_TIME TIMESTAMP,  TBSP_TOTAL_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  REBALANCER_MODE VARCHAR(30),  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  REBALANCER_LAST_EXTENT_MOVED BIGINT,  TBSP_NUM_RANGES BIGINT,  TBSP_NUM_CONTAINERS BIGINT,  TBSP_INITIAL_SIZE BIGINT,  TBSP_CURRENT_SIZE BIGINT,  TBSP_MAX_SIZE BIGINT,  TBSP_INCREASE_SIZE BIGINT,  TBSP_INCREASE_SIZE_PERCENT SMALLINT,  TBSP_LAST_RESIZE_TIME TIMESTAMP,  TBSP_LAST_RESIZE_FAILED SMALLINT,  DBPARTITIONNUM SMALLINT,  TBSP_PATHS_DROPPED SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_PART_V97_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_part_v97_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V97" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_STATE VARCHAR(256),  TBSP_PREFETCH_SIZE BIGINT,  TBSP_NUM_QUIESCERS BIGINT,  TBSP_STATE_CHANGE_OBJECT_ID BIGINT,  TBSP_STATE_CHANGE_TBSP_ID BIGINT,  TBSP_MIN_RECOVERY_TIME TIMESTAMP,  TBSP_TOTAL_PAGES BIGINT,  TBSP_USABLE_PAGES BIGINT,  TBSP_USED_PAGES BIGINT,  TBSP_FREE_PAGES BIGINT,  TBSP_PENDING_FREE_PAGES BIGINT,  TBSP_PAGE_TOP BIGINT,  REBALANCER_MODE VARCHAR(30),  REBALANCER_EXTENTS_REMAINING BIGINT,  REBALANCER_EXTENTS_PROCESSED BIGINT,  REBALANCER_PRIORITY BIGINT,  REBALANCER_START_TIME TIMESTAMP,  REBALANCER_RESTART_TIME TIMESTAMP,  REBALANCER_LAST_EXTENT_MOVED BIGINT,  TBSP_NUM_RANGES BIGINT,  TBSP_NUM_CONTAINERS BIGINT,  TBSP_INITIAL_SIZE BIGINT,  TBSP_CURRENT_SIZE BIGINT,  TBSP_MAX_SIZE BIGINT,  TBSP_INCREASE_SIZE BIGINT,  TBSP_INCREASE_SIZE_PERCENT SMALLINT,  TBSP_LAST_RESIZE_TIME TIMESTAMP,  TBSP_LAST_RESIZE_FAILED SMALLINT,  DBPARTITIONNUM SMALLINT,  TBSP_PATHS_DROPPED SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_PART_V97"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_part_v97"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_QUIESCER" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  QUIESCER_TS_ID BIGINT,  QUIESCER_OBJ_ID BIGINT,  QUIESCER_AUTH_ID VARCHAR(128),  QUIESCER_AGENT_ID BIGINT,  QUIESCER_STATE VARCHAR(14),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_QUIESCER_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_quiescer_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_QUIESCER" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  QUIESCER_TS_ID BIGINT,  QUIESCER_OBJ_ID BIGINT,  QUIESCER_AUTH_ID VARCHAR(128),  QUIESCER_AGENT_ID BIGINT,  QUIESCER_STATE VARCHAR(14),  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_QUIESCER"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_quiescer"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_RANGE" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_ID BIGINT,  TBSP_NAME VARCHAR(128),  RANGE_NUMBER BIGINT,  RANGE_STRIPE_SET_NUMBER BIGINT,  RANGE_OFFSET BIGINT,  RANGE_MAX_PAGE BIGINT,  RANGE_MAX_EXTENT BIGINT,  RANGE_START_STRIPE BIGINT,  RANGE_END_STRIPE BIGINT,  RANGE_ADJUSTMENT BIGINT,  RANGE_NUM_CONTAINER BIGINT,  RANGE_CONTAINER_ID BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_RANGE_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_range_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_RANGE" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_ID BIGINT,  TBSP_NAME VARCHAR(128),  RANGE_NUMBER BIGINT,  RANGE_STRIPE_SET_NUMBER BIGINT,  RANGE_OFFSET BIGINT,  RANGE_MAX_PAGE BIGINT,  RANGE_MAX_EXTENT BIGINT,  RANGE_START_STRIPE BIGINT,  RANGE_END_STRIPE BIGINT,  RANGE_ADJUSTMENT BIGINT,  RANGE_NUM_CONTAINER BIGINT,  RANGE_CONTAINER_ID BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_RANGE"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_range"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_V91" (DBNAME VARCHAR(128))
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_TYPE VARCHAR(10),  TBSP_CONTENT_TYPE VARCHAR(10),  TBSP_PAGE_SIZE BIGINT,  TBSP_EXTENT_SIZE BIGINT,  TBSP_PREFETCH_SIZE BIGINT,  TBSP_CUR_POOL_ID BIGINT,  TBSP_NEXT_POOL_ID BIGINT,  FS_CACHING SMALLINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  TBSP_REBALANCER_MODE VARCHAR(10),  TBSP_USING_AUTO_STORAGE SMALLINT,  TBSP_AUTO_RESIZE_ENABLED SMALLINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_V91_AP"
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_v91_ap"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_TBSP_V91" (DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  TBSP_NAME VARCHAR(128),  TBSP_ID BIGINT,  TBSP_TYPE VARCHAR(10),  TBSP_CONTENT_TYPE VARCHAR(10),  TBSP_PAGE_SIZE BIGINT,  TBSP_EXTENT_SIZE BIGINT,  TBSP_PREFETCH_SIZE BIGINT,  TBSP_CUR_POOL_ID BIGINT,  TBSP_NEXT_POOL_ID BIGINT,  FS_CACHING SMALLINT,  POOL_DATA_L_READS BIGINT,  POOL_DATA_P_READS BIGINT,  POOL_TEMP_DATA_L_READS BIGINT,  POOL_TEMP_DATA_P_READS BIGINT,  POOL_ASYNC_DATA_READS BIGINT,  POOL_DATA_WRITES BIGINT,  POOL_ASYNC_DATA_WRITES BIGINT,  POOL_INDEX_L_READS BIGINT,  POOL_INDEX_P_READS BIGINT,  POOL_TEMP_INDEX_L_READS BIGINT,  POOL_TEMP_INDEX_P_READS BIGINT,  POOL_ASYNC_INDEX_READS BIGINT,  POOL_INDEX_WRITES BIGINT,  POOL_ASYNC_INDEX_WRITES BIGINT,  POOL_XDA_L_READS BIGINT,  POOL_XDA_P_READS BIGINT,  POOL_XDA_WRITES BIGINT,  POOL_ASYNC_XDA_READS BIGINT,  POOL_ASYNC_XDA_WRITES BIGINT,  POOL_TEMP_XDA_L_READS BIGINT,  POOL_TEMP_XDA_P_READS BIGINT,  POOL_READ_TIME BIGINT,  POOL_WRITE_TIME BIGINT,  POOL_ASYNC_READ_TIME BIGINT,  POOL_ASYNC_WRITE_TIME BIGINT,  POOL_ASYNC_DATA_READ_REQS BIGINT,  POOL_ASYNC_INDEX_READ_REQS BIGINT,  POOL_ASYNC_XDA_READ_REQS BIGINT,  POOL_NO_VICTIM_BUFFER BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT,  DIRECT_READ_REQS BIGINT,  DIRECT_WRITE_REQS BIGINT,  DIRECT_READ_TIME BIGINT,  DIRECT_WRITE_TIME BIGINT,  FILES_CLOSED BIGINT,  UNREAD_PREFETCH_PAGES BIGINT,  TBSP_REBALANCER_MODE VARCHAR(10),  TBSP_USING_AUTO_STORAGE SMALLINT,  TBSP_AUTO_RESIZE_ENABLED SMALLINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_TBSP_V91"
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_tbsp_v91"
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_UTIL" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UTILITY_ID INTEGER,  UTILITY_TYPE VARCHAR(26),  UTILITY_PRIORITY INTEGER,  UTILITY_DESCRIPTION VARCHAR(2048),  UTILITY_DBNAME VARCHAR(128),  UTILITY_START_TIME TIMESTAMP,  UTILITY_STATE VARCHAR(10),  UTILITY_INVOKER_TYPE VARCHAR(10),  DBPARTITIONNUM SMALLINT,  PROGRESS_LIST_ATTR VARCHAR(10),  PROGRESS_LIST_CUR_SEQ_NUM INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_UTIL_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_util_ap"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_UTIL" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UTILITY_ID INTEGER,  UTILITY_TYPE VARCHAR(26),  UTILITY_PRIORITY INTEGER,  UTILITY_DESCRIPTION VARCHAR(2048),  UTILITY_DBNAME VARCHAR(128),  UTILITY_START_TIME TIMESTAMP,  UTILITY_STATE VARCHAR(10),  UTILITY_INVOKER_TYPE VARCHAR(10),  DBPARTITIONNUM SMALLINT,  PROGRESS_LIST_ATTR VARCHAR(10),  PROGRESS_LIST_CUR_SEQ_NUM INTEGER)
	SPECIFIC "SYSPROC"."SNAP_GET_UTIL"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_util"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_UTIL_PROGRESS" ()
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UTILITY_ID INTEGER,  PROGRESS_SEQ_NUM INTEGER,  UTILITY_STATE VARCHAR(16),  PROGRESS_DESCRIPTION VARCHAR(2048),  PROGRESS_START_TIME TIMESTAMP,  PROGRESS_WORK_METRIC VARCHAR(16),  PROGRESS_TOTAL_UNITS BIGINT,  PROGRESS_COMPLETED_UNITS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_UTIL_PROGRESS_AP"
	DETERMINISTIC
	NO SQL
	ALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_util_progress_ap"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SNAP_GET_UTIL_PROGRESS" (DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SNAPSHOT_TIMESTAMP TIMESTAMP,  UTILITY_ID INTEGER,  PROGRESS_SEQ_NUM INTEGER,  UTILITY_STATE VARCHAR(16),  PROGRESS_DESCRIPTION VARCHAR(2048),  PROGRESS_START_TIME TIMESTAMP,  PROGRESS_WORK_METRIC VARCHAR(16),  PROGRESS_TOTAL_UNITS BIGINT,  PROGRESS_COMPLETED_UNITS BIGINT,  DBPARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAP_GET_UTIL_PROGRESS"
	DETERMINISTIC
	NO SQL
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2monudf!snap_get_util_progress"
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	SCRATCHPAD 100;

CREATE FUNCTION "SYSPROC"."SQLERRM" (MSGID VARCHAR(9), 
		TOKENS VARCHAR(70), 
		TOKEN_DELIMITER VARCHAR(1), 
		LOCALE VARCHAR(33), 
		SHORTMSG INTEGER)
	RETURNS VARCHAR(32672)
	SPECIFIC "SYSPROC"."SQLERRM"
	DETERMINISTIC
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!sqlerrm"
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL;

CREATE FUNCTION "SYSPROC"."WLM_GET_ACTIVITY_DETAILS" (APPLICATION_HANDLE BIGINT, 
		UOW_ID INTEGER, 
		ACTIVITY_ID INTEGER, 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (DBPARTITIONNUM SMALLINT,  NAME VARCHAR(256),  VALUE VARCHAR(1024))
	SPECIFIC "SYSPROC"."WLM_GET_ACTIVITY_DETAILS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetActivityDetails"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_CONN_ENV" (APPLICATION_HANDLE BIGINT)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  DETAILS BLOB(8388608))
	SPECIFIC "SYSPROC"."WLM_GET_CONN_ENV"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbrouttrusted!wlmGetConnEnv"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_QUEUE_STATS" (THRESHOLD_PREDICATE VARCHAR(27), 
		THRESHOLD_DOMAIN VARCHAR(18), 
		THRESHOLD_NAME VARCHAR(128), 
		THRESHOLD_ID INTEGER)
	RETURNS TABLE (THRESHOLD_PREDICATE VARCHAR(27),  THRESHOLD_DOMAIN VARCHAR(18),  THRESHOLD_NAME VARCHAR(128),  THRESHOLD_ID INTEGER,  DBPARTITIONNUM SMALLINT,  SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  WORK_ACTION_SET_NAME VARCHAR(128),  WORK_CLASS_NAME VARCHAR(128),  WORKLOAD_NAME VARCHAR(128),  LAST_RESET TIMESTAMP,  QUEUE_SIZE_TOP INTEGER,  QUEUE_TIME_TOTAL BIGINT,  QUEUE_ASSIGNMENTS_TOTAL BIGINT,  QUEUE_SIZE_CURRENT INTEGER,  QUEUE_TIME_LATEST BIGINT,  QUEUE_EXIT_TIME_LATEST TIMESTAMP,  THRESHOLD_CURRENT_CONCURRENCY INTEGER,  THRESHOLD_MAX_CONCURRENCY INTEGER)
	SPECIFIC "SYSPROC"."WLM_GET_QUEUE_STATS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetQueueStats"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_CLASS_AGENTS" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		APPLICATION_HANDLE BIGINT, 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  APPLICATION_HANDLE BIGINT,  DBPARTITIONNUM SMALLINT,  ENTITY VARCHAR(32),  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  ACTIVITY_ID INTEGER,  PARENT_UOW_ID INTEGER,  PARENT_ACTIVITY_ID INTEGER,  AGENT_TID BIGINT,  AGENT_TYPE VARCHAR(32),  SMP_COORDINATOR INTEGER,  AGENT_SUBTYPE VARCHAR(32),  AGENT_STATE VARCHAR(32),  EVENT_TYPE VARCHAR(32),  EVENT_OBJECT VARCHAR(32),  EVENT_STATE VARCHAR(32),  REQUEST_ID VARCHAR(64),  REQUEST_TYPE VARCHAR(32),  NESTING_LEVEL INTEGER,  INVOCATION_ID INTEGER,  ROUTINE_ID INTEGER)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_CLASS_AGENTS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceClassAgents"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_CLASS_AGENTS_V97" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		APPLICATION_HANDLE BIGINT, 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  APPLICATION_HANDLE BIGINT,  DBPARTITIONNUM SMALLINT,  ENTITY VARCHAR(32),  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  ACTIVITY_ID INTEGER,  PARENT_UOW_ID INTEGER,  PARENT_ACTIVITY_ID INTEGER,  AGENT_TID BIGINT,  AGENT_TYPE VARCHAR(32),  SMP_COORDINATOR INTEGER,  AGENT_SUBTYPE VARCHAR(32),  AGENT_STATE VARCHAR(32),  EVENT_TYPE VARCHAR(32),  EVENT_OBJECT VARCHAR(32),  EVENT_STATE VARCHAR(32),  REQUEST_ID VARCHAR(64),  REQUEST_TYPE VARCHAR(32),  NESTING_LEVEL INTEGER,  INVOCATION_ID INTEGER,  ROUTINE_ID INTEGER,  EVENT_OBJECT_NAME VARCHAR(1024),  APPLICATION_NAME VARCHAR(128),  APPLICATION_ID VARCHAR(128),  CLIENT_PID BIGINT,  SESSION_AUTH_ID VARCHAR(128),  REQUEST_START_TIME TIMESTAMP,  AGENT_STATE_LAST_UPDATE_TIME TIMESTAMP,  EXECUTABLE_ID VARCHAR (32) FOR BIT DATA)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_CLASS_AGENTS_V97"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceClassAgents_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  COORD_PARTITION_NUM SMALLINT,  APPLICATION_HANDLE BIGINT,  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  WORKLOAD_OCCURRENCE_STATE VARCHAR(32),  SYSTEM_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  APPLICATION_NAME VARCHAR(128),  CLIENT_WRKSTNNAME VARCHAR(255),  CLIENT_ACCTNG VARCHAR(255),  CLIENT_USER VARCHAR(255),  CLIENT_APPLNAME VARCHAR(255),  COORD_ACT_COMPLETED_TOTAL INTEGER,  COORD_ACT_ABORTED_TOTAL INTEGER,  COORD_ACT_REJECTED_TOTAL INTEGER,  CONCURRENT_ACT_TOP INTEGER)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceClassWorkloadOccurrences"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES_V97" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  COORD_PARTITION_NUM SMALLINT,  APPLICATION_HANDLE BIGINT,  WORKLOAD_NAME VARCHAR(128),  WORKLOAD_OCCURRENCE_ID INTEGER,  UOW_ID INTEGER,  WORKLOAD_OCCURRENCE_STATE VARCHAR(32),  SYSTEM_AUTH_ID VARCHAR(128),  SESSION_AUTH_ID VARCHAR(128),  APPLICATION_NAME VARCHAR(128),  CLIENT_WRKSTNNAME VARCHAR(255),  CLIENT_ACCTNG VARCHAR(255),  CLIENT_USER VARCHAR(255),  CLIENT_APPLNAME VARCHAR(255),  COORD_ACT_COMPLETED_TOTAL INTEGER,  COORD_ACT_ABORTED_TOTAL INTEGER,  COORD_ACT_REJECTED_TOTAL INTEGER,  CONCURRENT_ACT_TOP INTEGER,  ADDRESS VARCHAR(255))
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES_V97"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceClassWorkloadOccurrences_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_SUBCLASS_STATS" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  COORD_ACT_COMPLETED_TOTAL BIGINT,  COORD_ACT_ABORTED_TOTAL BIGINT,  COORD_ACT_REJECTED_TOTAL BIGINT,  CONCURRENT_ACT_TOP INTEGER,  COORD_ACT_LIFETIME_TOP BIGINT,  COORD_ACT_LIFETIME_AVG DOUBLE,  COORD_ACT_LIFETIME_STDDEV DOUBLE,  COORD_ACT_EXEC_TIME_AVG DOUBLE,  COORD_ACT_EXEC_TIME_STDDEV DOUBLE,  COORD_ACT_QUEUE_TIME_AVG DOUBLE,  COORD_ACT_QUEUE_TIME_STDDEV DOUBLE,  NUM_REQUESTS_ACTIVE BIGINT,  NUM_REQUESTS_TOTAL BIGINT,  REQUEST_EXEC_TIME_AVG DOUBLE,  REQUEST_EXEC_TIME_STDDEV DOUBLE,  REQUEST_EXEC_TIME_TOTAL BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_SUBCLASS_STATS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceSubClassStats"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_SUBCLASS_STATS_V97" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		SERVICE_SUBCLASS_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  SERVICE_SUBCLASS_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  COORD_ACT_COMPLETED_TOTAL BIGINT,  COORD_ACT_ABORTED_TOTAL BIGINT,  COORD_ACT_REJECTED_TOTAL BIGINT,  CONCURRENT_ACT_TOP INTEGER,  COORD_ACT_LIFETIME_TOP BIGINT,  COORD_ACT_LIFETIME_AVG DOUBLE,  COORD_ACT_LIFETIME_STDDEV DOUBLE,  COORD_ACT_EXEC_TIME_AVG DOUBLE,  COORD_ACT_EXEC_TIME_STDDEV DOUBLE,  COORD_ACT_QUEUE_TIME_AVG DOUBLE,  COORD_ACT_QUEUE_TIME_STDDEV DOUBLE,  NUM_REQUESTS_ACTIVE BIGINT,  NUM_REQUESTS_TOTAL BIGINT,  REQUEST_EXEC_TIME_AVG DOUBLE,  REQUEST_EXEC_TIME_STDDEV DOUBLE,  REQUEST_EXEC_TIME_TOTAL BIGINT,  ACT_REMAPPED_IN BIGINT,  ACT_REMAPPED_OUT BIGINT,  CONCURRENT_WLO_TOP INTEGER,  UOW_TOTAL_TIME_TOP BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_SUBCLASS_STATS_V97"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceSubClassStats_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_SERVICE_SUPERCLASS_STATS" (SERVICE_SUPERCLASS_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (SERVICE_SUPERCLASS_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  CONCURRENT_CONNECTION_TOP INTEGER)
	SPECIFIC "SYSPROC"."WLM_GET_SERVICE_SUPERCLASS_STATS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetServiceSuperClassStats"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES" (APPLICATION_HANDLE BIGINT, 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  DBPARTITIONNUM SMALLINT,  COORD_PARTITION_NUM SMALLINT,  LOCAL_START_TIME TIMESTAMP,  UOW_ID INTEGER,  ACTIVITY_ID INTEGER,  PARENT_UOW_ID INTEGER,  PARENT_ACTIVITY_ID INTEGER,  ACTIVITY_STATE VARCHAR(32),  ACTIVITY_TYPE VARCHAR(32),  NESTING_LEVEL INTEGER,  INVOCATION_ID INTEGER,  ROUTINE_ID INTEGER,  UTILITY_ID INTEGER,  SERVICE_CLASS_ID INTEGER,  DATABASE_WORK_ACTION_SET_ID INTEGER,  DATABASE_WORK_CLASS_ID INTEGER,  SERVICE_CLASS_WORK_ACTION_SET_ID INTEGER,  SERVICE_CLASS_WORK_CLASS_ID INTEGER)
	SPECIFIC "SYSPROC"."WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetWorkloadOccurrenceActivities"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97" (APPLICATION_HANDLE BIGINT, 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (APPLICATION_HANDLE BIGINT,  DBPARTITIONNUM SMALLINT,  COORD_PARTITION_NUM SMALLINT,  LOCAL_START_TIME TIMESTAMP,  UOW_ID INTEGER,  ACTIVITY_ID INTEGER,  PARENT_UOW_ID INTEGER,  PARENT_ACTIVITY_ID INTEGER,  ACTIVITY_STATE VARCHAR(32),  ACTIVITY_TYPE VARCHAR(32),  NESTING_LEVEL INTEGER,  INVOCATION_ID INTEGER,  ROUTINE_ID INTEGER,  UTILITY_ID INTEGER,  SERVICE_CLASS_ID INTEGER,  DATABASE_WORK_ACTION_SET_ID INTEGER,  DATABASE_WORK_CLASS_ID INTEGER,  SERVICE_CLASS_WORK_ACTION_SET_ID INTEGER,  SERVICE_CLASS_WORK_CLASS_ID INTEGER,  EXECUTABLE_ID VARCHAR (32) FOR BIT DATA,  TOTAL_CPU_TIME BIGINT,  ROWS_READ BIGINT,  ROWS_RETURNED BIGINT,  QUERY_COST_ESTIMATE BIGINT,  DIRECT_READS BIGINT,  DIRECT_WRITES BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetWorkloadOccurrenceActivities_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_WORKLOAD_STATS" (WORKLOAD_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (WORKLOAD_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  CONCURRENT_WLO_TOP INTEGER,  CONCURRENT_WLO_ACT_TOP INTEGER,  COORD_ACT_COMPLETED_TOTAL BIGINT,  COORD_ACT_ABORTED_TOTAL BIGINT,  COORD_ACT_REJECTED_TOTAL BIGINT,  WLO_COMPLETED_TOTAL BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_WORKLOAD_STATS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetWorkloadStats"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_WORKLOAD_STATS_V97" (WORKLOAD_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (WORKLOAD_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  CONCURRENT_WLO_TOP INTEGER,  CONCURRENT_WLO_ACT_TOP INTEGER,  COORD_ACT_COMPLETED_TOTAL BIGINT,  COORD_ACT_ABORTED_TOTAL BIGINT,  COORD_ACT_REJECTED_TOTAL BIGINT,  WLO_COMPLETED_TOTAL BIGINT,  COORD_ACT_LIFETIME_TOP BIGINT,  COORD_ACT_LIFETIME_AVG DOUBLE,  COORD_ACT_LIFETIME_STDDEV DOUBLE,  COORD_ACT_EXEC_TIME_AVG DOUBLE,  COORD_ACT_EXEC_TIME_STDDEV DOUBLE,  COORD_ACT_QUEUE_TIME_AVG DOUBLE,  COORD_ACT_QUEUE_TIME_STDDEV DOUBLE,  UOW_TOTAL_TIME_TOP BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_WORKLOAD_STATS_V97"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetWorkloadStats_v97"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION "SYSPROC"."WLM_GET_WORK_ACTION_SET_STATS" (WORK_ACTION_SET_NAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	RETURNS TABLE (WORK_ACTION_SET_NAME VARCHAR(128),  DBPARTITIONNUM SMALLINT,  LAST_RESET TIMESTAMP,  WORK_CLASS_NAME VARCHAR(128),  ACT_TOTAL BIGINT)
	SPECIFIC "SYSPROC"."WLM_GET_WORK_ACTION_SET_STATS"
	NO SQL
	NO EXTERNAL ACTION
	DISALLOW PARALLEL
	LANGUAGE C
	EXTERNAL NAME "db2dbroutext!wlmGetWorkActionSetStats"
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	SCRATCHPAD 32767;

CREATE FUNCTION SYSFUN.GROUPS()    RETURNS TABLE (GROUPNAME VARCHAR(30))    SPECIFIC GROUPS    LANGUAGE SQL    DETERMINISTIC    NO EXTERNAL ACTION    READS SQL DATA    RETURN SELECT T.NAME from TABLE(USERS_GROUPS(0,'')) as T;

CREATE FUNCTION SYSFUN.GROUPS_FOR_USER(USERNAME VARCHAR(30))    RETURNS TABLE (GROUPNAME VARCHAR(30))    SPECIFIC GROUPS_FOR_USER    LANGUAGE SQL    DETERMINISTIC    NO EXTERNAL ACTION    READS SQL DATA    RETURN SELECT T.NAME from TABLE(USERS_GROUPS(2,USERNAME)) as T;

CREATE FUNCTION SYSFUN.USERS()    RETURNS TABLE (USERNAME VARCHAR(30))    SPECIFIC USERS    LANGUAGE SQL    DETERMINISTIC    NO EXTERNAL ACTION    READS SQL DATA    RETURN SELECT T.NAME from TABLE(USERS_GROUPS(1,'')) as T;

CREATE FUNCTION SYSPROC.AUTH_LIST_ROLES_FOR_AUTHID ( AUTHID VARCHAR(128), AUTHIDTYPE VARCHAR(1) ) RETURNS TABLE ( GRANTOR VARCHAR(128), GRANTORTYPE CHAR(1), GRANTEE VARCHAR(128), GRANTEETYPE CHAR(1), ROLENAME VARCHAR(128), CREATE_TIME TIMESTAMP, ADMIN CHAR(1) ) SPECIFIC AUTH_LIST_ROLES_FOR_AUTHID LANGUAGE SQL DETERMINISTIC NO EXTERNAL ACTION READS SQL DATA CALLED ON NULL INPUT RETURN WITH GETGROUPS(GROUPNAME) AS ( SELECT GROUP FROM TABLE (SYSPROC.AUTH_LIST_GROUPS_FOR_AUTHID(AUTHID)) AS T ) ,GETROLES(LEVEL, DGRANTOR, DGRANTORTYPE, DGRANTEE, DGRANTEETYPE, DROLENAME, DCREATE_TIME, DADMIN) AS ( SELECT 1, U.GRANTOR, U.GRANTORTYPE, U.GRANTEE, U.GRANTEETYPE,  U.ROLENAME, U.CREATE_TIME, U.ADMIN FROM TABLE ( SELECT A.GRANTOR, A.GRANTORTYPE, A.GRANTEE, A.GRANTEETYPE, A.ROLENAME, B.CREATE_TIME, A.ADMIN FROM SYSIBM.SYSROLEAUTH AS A, SYSIBM.SYSROLES AS B WHERE A.GRANTEETYPE = AUTHIDTYPE AND A.ROLEID = B.ROLEID AND A.GRANTEE = AUTHID UNION ALL SELECT A.GRANTOR, A.GRANTORTYPE, A.GRANTEE, A.GRANTEETYPE, A.ROLENAME, B.CREATE_TIME, A.ADMIN FROM SYSIBM.SYSROLEAUTH AS A, SYSIBM.SYSROLES AS B, GETGROUPS WHERE AUTHIDTYPE = 'U' AND A.GRANTEETYPE = 'G' AND A.ROLEID = B.ROLEID AND A.GRANTEE = GETGROUPS.GROUPNAME UNION ALL SELECT A.GRANTOR, A.GRANTORTYPE, A.GRANTEE, A.GRANTEETYPE, A.ROLENAME, B.CREATE_TIME, A.ADMIN FROM SYSIBM.SYSROLEAUTH AS A, SYSIBM.SYSROLES AS B WHERE AUTHIDTYPE = 'U' AND A.GRANTEE = 'PUBLIC' AND A.ROLEID = B.ROLEID AND AUTHID != '' AND AUTHID IS NOT NULL ) AS U UNION ALL SELECT LEVEL+1, U.GRANTOR, U.GRANTORTYPE, U.GRANTEE, U.GRANTEETYPE, U.ROLENAME, U.CREATE_TIME, U.ADMIN FROM GETROLES, TABLE ( SELECT A.GRANTOR, A.GRANTORTYPE, A.GRANTEE, A.GRANTEETYPE, A.ROLENAME,  B.CREATE_TIME, A.ADMIN FROM SYSIBM.SYSROLEAUTH AS A, SYSIBM.SYSROLES AS B WHERE A.GRANTEE = GETROLES.DROLENAME AND A.GRANTEETYPE = 'R' AND A.ROLEID = B.ROLEID ) AS U WHERE (LEVEL < 1000000) ) SELECT DISTINCT DGRANTOR, DGRANTORTYPE, DGRANTEE, DGRANTEETYPE, DROLENAME, DCREATE_TIME, DADMIN FROM GETROLES;

CREATE FUNCTION SYSPROC.BASE_TABLE     (aliasschema VARCHAR(128), aliasname VARCHAR(128))RETURNS TABLE ( BASESCHEMA VARCHAR(128), BASENAME VARCHAR(128)) SPECIFIC BASE_TABLE DETERMINISTIC NO EXTERNAL ACTION RETURN WITH rec(baseschema, basename, level) AS (VALUES(aliasschema, aliasname, 10000) UNION ALL SELECT BASE_TABSCHEMA, BASE_TABNAME, level -1 FROM SYSCAT.TABLES, REC WHERE TABSCHEMA = BASESCHEMA AND TABNAME = BASENAME AND TYPE = 'A' AND level > 0) SELECT * FROM (SELECT BASESCHEMA, BASENAME FROM rec ORDER BY level FETCH FIRST ROW ONLY) AS X;

CREATE FUNCTION SYSPROC.DB2LK_DEP_FIRST ( DEPTYPE VARCHAR(1),SCHEMA  VARCHAR(128),NAME    VARCHAR(128)) RETURNS TABLE(OBJECTTYPE VARCHAR(1), SCHEMA VARCHAR(128), NAME VARCHAR(128), THIRDNAME VARCHAR(128), DEFINER VARCHAR(128), CTIME VARCHAR(27)) SPECIFIC DB2LK_DEP_FIRST READS SQL DATA NO EXTERNAL ACTION DETERMINISTIC RETURN SELECT 'F', T1.ROUTINESCHEMA, T1.SPECIFICNAME, T2.SPECIFICNAME, T2.DEFINER, T2.CREATE_TIME FROM SYSCAT.ROUTINEDEP T1, SYSCAT.ROUTINES T2 WHERE T1.BTYPE = DEPTYPE  AND T1.BSCHEMA = SCHEMA  AND T1.BNAME = NAME AND T1.ROUTINESCHEMA = T2.ROUTINESCHEMA AND T1.SPECIFICNAME = T2.SPECIFICNAME UNION ALL SELECT T1.DTYPE, T1.TABSCHEMA, T1.TABNAME, CAST(NULL AS VARCHAR(128)), T1.DEFINER, T2.CREATE_TIME FROM SYSCAT.TABDEP T1, SYSCAT.TABLES T2 WHERE T1.BTYPE = DEPTYPE  AND T1.BSCHEMA = SCHEMA AND T1.BNAME = NAME AND T1.TABSCHEMA = T2.TABSCHEMA AND T1.TABNAME = T2.TABNAME UNION ALL SELECT 'C', T1.TABSCHEMA, T1.TABNAME, T1.CONSTNAME, T2.DEFINER, T3.CREATE_TIME FROM SYSCAT.CONSTDEP T1, SYSCAT.TABCONST T2, SYSCAT.TABLES T3 WHERE T1.BTYPE = DEPTYPE AND T1.BSCHEMA = SCHEMA AND T1.BNAME = NAME AND T1.CONSTNAME = T2.CONSTNAME AND T1.TABSCHEMA = T2.TABSCHEMA AND T1.TABNAME = T2.TABNAME AND T1.TABSCHEMA = T3.TABSCHEMA AND T1.TABNAME = T3.TABNAME UNION ALL SELECT 'I', INDSCHEMA, INDNAME, CAST(NULL AS VARCHAR(128)), CAST(NULL AS VARCHAR(128)), CAST(NULL AS VARCHAR(27)) FROM SYSCAT.INDEXDEP WHERE BTYPE = DEPTYPE AND BSCHEMA = SCHEMA AND BNAME = NAME UNION ALL SELECT 'X', IESCHEMA, IENAME, CAST(NULL AS VARCHAR(128)), CAST(NULL AS VARCHAR(128)), CAST(NULL AS VARCHAR(27)) FROM SYSCAT.INDEXEXTENSIONDEP WHERE BTYPE = DEPTYPE  AND BSCHEMA = SCHEMA AND BNAME = NAME UNION ALL SELECT 'P', PKGSCHEMA, PKGNAME, UNIQUE_ID, CAST(NULL AS VARCHAR(128)), CAST(NULL AS VARCHAR(27)) FROM SYSCAT.PACKAGEDEP WHERE BTYPE = DEPTYPE  AND BSCHEMA = SCHEMA AND BNAME = NAME UNION ALL SELECT 'B', T1.TRIGSCHEMA, T1.TRIGNAME, CAST(NULL AS VARCHAR(128)), DEFINER, CREATE_TIME FROM SYSCAT.TRIGGERS T1, SYSCAT.TRIGDEP T2 WHERE T2.BTYPE = DEPTYPE AND T2.BSCHEMA = SCHEMA AND T2.BNAME = NAME AND T2.TRIGSCHEMA = T1.TRIGSCHEMA AND T2.TRIGNAME = T1.TRIGNAME UNION ALL SELECT 'C', TABSCHEMA, TABNAME, CONSTNAME, DEFINER, CREATE_TIME FROM  SYSCAT.REFERENCES WHERE ((REFTABSCHEMA = SCHEMA AND REFTABNAME = NAME) OR (TABSCHEMA = SCHEMA AND TABNAME = NAME)) AND DEPTYPE IN ('T', 'N', 'U', 'S') UNION ALL SELECT  'I', INDSCHEMA, INDNAME, CAST(NULL AS VARCHAR(128)), DEFINER, CREATE_TIME FROM SYSCAT.INDEXES WHERE DEPTYPE IN ('T', 'U', 'N', 'S') AND TABSCHEMA = SCHEMA AND TABNAME = NAME UNION ALL SELECT TYPE, TABSCHEMA, TABNAME, CAST(NULL AS VARCHAR(128)), DEFINER, CREATE_TIME FROM SYSCAT.TABLES WHERE DEPTYPE IN ('T', 'U', 'N', 'S')  AND BASE_TABSCHEMA = SCHEMA  AND BASE_TABNAME = NAME UNION ALL SELECT 'C',   TABSCHEMA,   TABNAME, CONSTNAME, DEFINER, CREATE_TIME FROM SYSCAT.CHECKS WHERE DEPTYPE IN ('T', 'U', 'N', 'S') AND TABSCHEMA = SCHEMA AND TABNAME = NAME;

CREATE FUNCTION SYSPROC.DB2LK_DEP_OF  ( DEPTYPE  VARCHAR(1),    SCHEMA   VARCHAR(128),    NAME     VARCHAR(128))  RETURNS TABLE(OBJECTTYPE VARCHAR(1),                SCHEMANAME VARCHAR(128),                OBJECTNAME VARCHAR(128),                THIRDNAME  VARCHAR(128),                DEFINER    VARCHAR(128),               CTIME      VARCHAR(27))  SPECIFIC DB2LK_DEP_OF  READS SQL DATA NO EXTERNAL ACTION DETERMINISTIC  RETURN WITH REC(LEVEL, DTYPE, DSCHEMA, DNAME, DTHIRD, DEFINER, CTIME)    AS ( SELECT 1, U.* FROM      TABLE (SYSPROC.DB2LK_DEP_FIRST(DEPTYPE, SCHEMA, NAME)) AS U    UNION ALL SELECT LEVEL + 1, U.*    FROM REC,      TABLE(SYSPROC.DB2LK_DEP_FIRST(REC.DTYPE, REC.DSCHEMA, REC.DNAME)) AS U    WHERE LEVEL < 1000000)    SELECT DISTINCT DTYPE, DSCHEMA, DNAME, DTHIRD, DEFINER, CTIME FROM REC;

CREATE FUNCTION SYSPROC.GET_INDEX_COLNAMES ( INDEX_SCHEMA VARCHAR(128), INDEX_NAME VARCHAR(128) ) RETURNS VARCHAR(1984) SPECIFIC GET_INDEX_COLNAMES LANGUAGE SQL READS SQL DATA BEGIN ATOMIC DECLARE INDEX_COLNAMES VARCHAR(1984) DEFAULT ''; DECLARE COL_COUNTER INT DEFAULT 1; DECLARE NUM_OF_COLS SMALLINT; SET NUM_OF_COLS = (SELECT COLCOUNT FROM SYSCAT.INDEXES WHERE INDSCHEMA = INDEX_SCHEMA AND INDNAME = INDEX_NAME); WHILE COL_COUNTER <= NUM_OF_COLS DO SET INDEX_COLNAMES = INDEX_COLNAMES || (SELECT CASE COLORDER WHEN 'D' THEN '-' ELSE '+' END || COLNAME FROM SYSCAT.INDEXCOLUSE WHERE INDSCHEMA = INDEX_SCHEMA AND INDNAME = INDEX_NAME AND COLSEQ = COL_COUNTER); SET COL_COUNTER = COL_COUNTER + 1; END WHILE; RETURN( INDEX_COLNAMES ); END;

CREATE FUNCTION SYSPROC.MON_FORMAT_XML_TIMES_BY_ROW (        XMLDOC                   BLOB(100M)   )  RETURNS TABLE (METRIC_NAME VARCHAR(128),                  TOTAL_TIME_VALUE BIGINT,                  COUNT BIGINT,                  PARENT_METRIC_NAME VARCHAR(128))   SPECIFIC MON_FORMAT_XML_TIMES_BY_ROW   LANGUAGE SQL                            NO EXTERNAL ACTION READS SQL DATA NOT DETERMINISTIC  RETURN        (             (SELECT METRIC_NAME,             TOTAL_TIME_VALUE,             COUNT,             PARENT_METRIC_NAME             FROM TABLE (MON_FORMAT_XML_WAIT_TIMES_BY_ROW(XMLDOC)) AS W             WHERE PARENT_METRIC_NAME IS NOT NULL OR             METRIC_NAME = 'CLIENT_IDLE_WAIT_TIME' OR             METRIC_NAME = 'WLM_QUEUE_TIME_TOTAL'             )             UNION ALL             (SELECT PROC_METRIC_NAME AS METRIC_NAME,             PROC_TIME_VALUE AS TOTAL_TIME_VALUE,             COUNT,             PARENT_PROC_METRIC_NAME AS PARENT_METRIC_NAME             FROM TABLE(MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW(XMLDOC)) AS P             WHERE PROC_METRIC_NAME IS NOT NULL             )             UNION ALL             (SELECT METRIC_NAME,             TOTAL_TIME_VALUE,             COUNT,             PARENT_METRIC_NAME             FROM TABLE (MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW(XMLDOC)) AS S              WHERE METRIC_NAME='TOTAL_RQST_TIME' OR             METRIC_NAME='STMT_EXEC_TIME'             )             );

CREATE FUNCTION resign_employee (number CHAR(6))
  RETURNS TABLE (empno  CHAR(6),
                 salary DOUBLE,
                 dept   CHAR(3))
  MODIFIES SQL DATA
  LANGUAGE SQL
  BEGIN ATOMIC
-- -------------------------------------------------------------------------------------
-- Routine type:  SQL table function
-- Routine name:  resign_employee
--
-- Purpose:  This procedure takes in an employee number, then removes that
--           employee from the EMPLOYEE table.
--           A useful extension to this function would be to archive the
--           original record into an archive table.
--
-- --------------------------------------------------------------------------------------
    DECLARE l_salary DOUBLE;
    DECLARE l_job CHAR(3);

    SET (l_salary, l_job) = (SELECT salary, job
                               FROM OLD TABLE (DELETE FROM employee
                                                WHERE employee.empno = number));

    RETURN VALUES (number,l_salary, l_job);
  END;

CREATE OR REPLACE FUNCTION SYSPROC.SQLERRM (   IN_SQLCODE   INTEGER ) RETURNS VARCHAR(32672) SPECIFIC SQLERRM_EXT LANGUAGE SQL CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION CALLED ON NULL INPUT RETURN SQLERRM(CONCAT('SQL', CHAR(ABS(IN_SQLCODE))) , '', '', '', 1);

CREATE PROCEDURE "SQLJ"."DB2_INSTALL_JAR" (FILEASBLOB BLOB(10485760), 
		JARID VARCHAR(261))
	SPECIFIC "SQLJ"."DB2_INSTALL_JAR2"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!db2installjar2";

CREATE PROCEDURE "SQLJ"."DB2_INSTALL_JAR" (FILEASBLOB BLOB(10485760), 
		JARID VARCHAR(261), 
		DEPLOY INTEGER)
	SPECIFIC "SQLJ"."DB2_INSTALL_JAR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!db2installjar";

CREATE PROCEDURE "SQLJ"."DB2_REPLACE_JAR" (FILEASBLOB BLOB(10485760), 
		JARID VARCHAR(261))
	SPECIFIC "SQLJ"."DB2_REPLACE_JAR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!db2replacejar";

CREATE PROCEDURE "SQLJ"."DB2_UPDATEJARINFO" (JARID VARCHAR(261), 
		CLASS VARCHAR(128), 
		FILEASBLOB BLOB(10485760))
	SPECIFIC "SQLJ"."DB2_UPDATEJARINFO"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!db2updatejarinfo";

CREATE PROCEDURE "SQLJ"."RECOVERJAR" (JARID VARCHAR(261))
	SPECIFIC "SQLJ"."RECOVERJAR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!recoverjar";

CREATE PROCEDURE "SQLJ"."REFRESH_CLASSES" ()
	SPECIFIC "SQLJ"."REFRESH_CLASSES"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!refreshclasses";

CREATE PROCEDURE "SQLJ"."REMOVE_JAR" (JARID VARCHAR(261))
	SPECIFIC "SQLJ"."REMOVE_JAR2"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!removejar2";

CREATE PROCEDURE "SQLJ"."REMOVE_JAR" (JARID VARCHAR(261), 
		DEPLOY INTEGER)
	SPECIFIC "SQLJ"."REMOVE_JAR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2jarsp!removejar";

CREATE PROCEDURE "SYSFUN"."GET_ROUTINE_SAR" (OUT SAR BLOB(3145728), 
		TYPE CHAR(2), 
		NAME VARCHAR(257))
	SPECIFIC "SYSFUN"."GET_SAR"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!get_routine_sar";

CREATE PROCEDURE "SYSFUN"."GET_ROUTINE_SAR" (OUT SAR BLOB(3145728), 
		TYPE CHAR(2), 
		NAME VARCHAR(257), 
		HIDE_BODY_FLAG INTEGER)
	SPECIFIC "SYSFUN"."GET_SAR4PARM"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!get_routine_sar_4parm";

CREATE PROCEDURE "SYSFUN"."PUT_ROUTINE_SAR" (SAR BLOB(3145728))
	SPECIFIC "SYSFUN"."PUT_SAR1PARM"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!put_routine_sar_1parm";

CREATE PROCEDURE "SYSFUN"."PUT_ROUTINE_SAR" (SAR BLOB(3145728), 
		OWNER VARCHAR(128), 
		FLAG INTEGER)
	SPECIFIC "SYSFUN"."PUT_SAR"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!put_routine_sar";

CREATE PROCEDURE "SYSIBM"."SQLATTRIBUTES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TYPE_NAME VARCHAR(128), 
		ATTRIBUTE_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."ATTRIBUTES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlattributes";

CREATE PROCEDURE "SYSIBM"."SQLCAMESSAGE" (SQLCODE INTEGER, 
		SQLERRML SMALLINT, 
		SQLERRMC VARCHAR(70), 
		SQLERRP CHAR(8), 
		SQLERRD0 INTEGER, 
		SQLERRD1 INTEGER, 
		SQLERRD2 INTEGER, 
		SQLERRD3 INTEGER, 
		SQLERRD4 INTEGER, 
		SQLERRD5 INTEGER, 
		SQLWARN CHAR(11), 
		SQLSTATE CHAR(5), 
		MESSAGEFILENAME VARCHAR(20), 
		INOUT LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(4096), 
		OUT RCODE INTEGER)
	SPECIFIC "SYSIBM"."SQLCAMESSAGE"
	NO SQL
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2msg!sqlGetServerMsg";

CREATE PROCEDURE "SYSIBM"."SQLCAMESSAGECCSID" (SQLCODE INTEGER, 
		SQLERRML SMALLINT, 
		SQLERRMC VARCHAR(70), 
		SQLERRP CHAR(8), 
		SQLERRD0 INTEGER, 
		SQLERRD1 INTEGER, 
		SQLERRD2 INTEGER, 
		SQLERRD3 INTEGER, 
		SQLERRD4 INTEGER, 
		SQLERRD5 INTEGER, 
		SQLWARN CHAR(11), 
		SQLSTATE CHAR(5), 
		MESSAGEFILENAME VARCHAR(20), 
		INOUT LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(4096), 
		OUT RCODE INTEGER, 
		INOUT CCSID INTEGER)
	SPECIFIC "SYSIBM"."SQLCAMESSAGECCSID"
	NO SQL
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2msg!sqlGetServerMsgCCSID";

CREATE PROCEDURE "SYSIBM"."SQLCOLPRIVILEGES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TABLE_NAME VARCHAR(128), 
		COL_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."COLPRIVILEGES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlcolprivileges";

CREATE PROCEDURE "SYSIBM"."SQLCOLUMNS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		TABLE_NAME VARCHAR(256), 
		COL_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."COLUMNS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlcolumns";

CREATE PROCEDURE "SYSIBM"."SQLFOREIGNKEYS" (PKCATALOG_NAME VARCHAR(128), 
		PKSCHEMA_NAME VARCHAR(128), 
		PKTABLE_NAME VARCHAR(128), 
		FKCATALOG_NAME VARCHAR(128), 
		FKSCHEMA_NAME VARCHAR(128), 
		FKTABLE_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."FOREIGNKEYS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlforeignkeys";

CREATE PROCEDURE "SYSIBM"."SQLFUNCTIONCOLS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		FUNCTION_NAME VARCHAR(128), 
		PARAMETER_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."FUNCTIONCOLS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlfunctioncols";

CREATE PROCEDURE "SYSIBM"."SQLFUNCTIONS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		FUNCTION_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."FUNCTIONS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlfunctions";

CREATE PROCEDURE "SYSIBM"."SQLGETTYPEINFO" (DATATYPE SMALLINT, 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."GETTYPEINFO"
	READS SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlgettypeinfo";

CREATE PROCEDURE "SYSIBM"."SQLPRIMARYKEYS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TABLE_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."PRIMARYKEYS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlprimarykeys";

CREATE PROCEDURE "SYSIBM"."SQLPROCEDURECOLS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		PROC_NAME VARCHAR(256), 
		COL_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."PROCEDURECOLS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlprocedurecols";

CREATE PROCEDURE "SYSIBM"."SQLPROCEDURES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		PROC_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."PROCEDURES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlprocedures";

CREATE PROCEDURE "SYSIBM"."SQLPSEUDOCOLUMNS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		TABLE_NAME VARCHAR(256), 
		COL_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."PSEUDOCOLUMNS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlpseudocolumns";

CREATE PROCEDURE "SYSIBM"."SQLSPECIALCOLUMNS" (COLTYPE SMALLINT, 
		CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TABLE_NAME VARCHAR(128), 
		SCOPE SMALLINT, 
		NULLABLE SMALLINT, 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."SPECIALCOLUMNS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlspecialcolumns";

CREATE PROCEDURE "SYSIBM"."SQLSTATISTICS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TABLE_NAME VARCHAR(128), 
		UNIQUE SMALLINT, 
		RESERVED SMALLINT, 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."STATISTICS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlstatistics";

CREATE PROCEDURE "SYSIBM"."SQLSUPERTABLES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TABLE_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."SUPERTABLES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlsupertables";

CREATE PROCEDURE "SYSIBM"."SQLSUPERTYPES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128), 
		TYPE_NAME VARCHAR(128), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."SUPERTYPES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqlsupertypes";

CREATE PROCEDURE "SYSIBM"."SQLTABLEPRIVILEGES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		TABLE_NAME VARCHAR(256), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."TABLEPRIVILEGES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqltableprivileges";

CREATE PROCEDURE "SYSIBM"."SQLTABLES" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		TABLE_NAME VARCHAR(256), 
		TABLE_TYPE VARCHAR(4000), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."TABLES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqltables";

CREATE PROCEDURE "SYSIBM"."SQLUDTS" (CATALOG_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(256), 
		TYPE_NAME VARCHAR(256), 
		TYPES VARCHAR(18), 
		OPTIONS VARCHAR(4000))
	SPECIFIC "SYSIBM"."UDTS"
	READS SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2schema!sqludts";

CREATE PROCEDURE "SYSIBMADM"."RAISE_APPLICATION_ERROR" (NUM INTEGER, 
		MSG VARCHAR(2000))
	SPECIFIC "SYSIBMADM"."RAISE_APPLICATION_ERROR"
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2modlib!sqleml_raise_application_error";

CREATE PROCEDURE "SYSPROC"."ADMIN_CMD" (CMD CLOB(2097152))
	SPECIFIC "SYSPROC"."ADMIN_CMD"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 2
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2admcmd!admin_cmd";

CREATE PROCEDURE "SYSPROC"."ADMIN_COPY_SCHEMA" (SOURCESCHEMA VARCHAR(128), 
		TARGETSCHEMA VARCHAR(128), 
		COPYMODE VARCHAR(128), 
		OBJECTOWNER VARCHAR(128), 
		SOURCETBSP CLOB(2097152), 
		TARGETTBSP CLOB(2097152), 
		INOUT ERRORTABSCHEMA VARCHAR(128), 
		INOUT ERRORTABNAME VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_COPY_SCHEMA"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2copyschema!copySchema";

CREATE PROCEDURE "SYSPROC"."ADMIN_DROP_SCHEMA" (SCHEMA VARCHAR(128), 
		DROPMODE VARCHAR(128), 
		INOUT ERRORTABSCHEMA VARCHAR(128), 
		INOUT ERRORTAB VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_DROP_SCHEMA"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2copyschema!dropSchema";

CREATE PROCEDURE "SYSPROC"."ADMIN_GET_DEPTREE" (OBJECTTYPE VARCHAR(128), 
		OBJECTLIST CLOB(2097152), 
		INOUT DMTSCHEMA VARCHAR(128), 
		INOUT DMTNAME VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_GET_DEPTREE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2copyschema!getDependencies";

CREATE PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		DATA_TBSP VARCHAR(128), 
		INDEX_TBSP VARCHAR(128), 
		LOB_TBSP VARCHAR(128), 
		MDC_COLS VARCHAR(32672), 
		PARTKEY_COLS VARCHAR(32672), 
		RANGE_PART VARCHAR(32672), 
		COLDEF VARCHAR(32672), 
		OPTIONS VARCHAR(32672), 
		OPERATION VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_MOVE_TABLE1"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!admin_move_table_nf1";

CREATE PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		TARGET_TAB_NAME VARCHAR(128), 
		OPTIONS VARCHAR(32672), 
		OPERATION VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_MOVE_TABLE2"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!admin_move_table_nf2";

CREATE PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE_UTIL" (TABSCHEMA VARCHAR(128), 
		TABNAME VARCHAR(128), 
		ACTION VARCHAR(128), 
		KEY VARCHAR(128), 
		VALUE CLOB(10485760))
	SPECIFIC "SYSPROC"."ADMIN_MOVE_TABLE_UTIL"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!admin_move_table_util";

CREATE PROCEDURE "SYSPROC"."ADMIN_REMOVE_MSGS" (OPERATION_ID VARCHAR(139))
	SPECIFIC "SYSPROC"."ADMIN_REMOVE_MSGS"
	NO SQL
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2admcmd!admin_remove_msgs";

CREATE PROCEDURE "SYSPROC"."ADMIN_REVALIDATE_DB_OBJECTS" (OBJECT_TYPE VARCHAR(30), 
		OBJECT_SCHEMA VARCHAR(128), 
		OBJECT_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."ADMIN_REVALIDATE_DB_OBJECTS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!admin_revalidate_db_objects";

CREATE PROCEDURE "SYSPROC"."ADMIN_SP_C" (LIB_NAME VARCHAR(128), 
		ADMIN_PROC_NAME VARCHAR(128), 
		FREE_PROC_NAME VARCHAR(128), 
		XML BLOB(262144), 
		OUT SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."ADMIN_SP_C"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!admin_sp";

CREATE PROCEDURE "SYSPROC"."ADMIN_SP_C2" (LIB_NAME VARCHAR(128), 
		ADMIN_PROC_NAME VARCHAR(128), 
		FREE_PROC_NAME VARCHAR(128), 
		XML BLOB(262144))
	SPECIFIC "SYSPROC"."ADMIN_SP_C2"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!admin_sp2";

CREATE PROCEDURE "SYSPROC"."ADMIN_TASK_ADD" (NAME VARCHAR(128), 
		BEGIN_TIME TIMESTAMP, 
		END_TIME TIMESTAMP, 
		MAX_INVOCATIONS INTEGER, 
		SCHEDULE VARCHAR(1024), 
		PROCEDURE_SCHEMA VARCHAR(128), 
		PROCEDURE_NAME VARCHAR(128), 
		PROCEDURE_INPUT CLOB(2097152), 
		OPTIONS VARCHAR(512), 
		REMARKS VARCHAR(254))
	SPECIFIC "SYSPROC"."ADMIN_TASK_ADD"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!adminTaskAdd";

CREATE PROCEDURE "SYSPROC"."ADMIN_TASK_REMOVE" (NAME VARCHAR(128), 
		END_TIME TIMESTAMP)
	SPECIFIC "SYSPROC"."ADMIN_TASK_REMOVE"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!adminTaskRemove";

CREATE PROCEDURE "SYSPROC"."ADMIN_TASK_UPDATE" (NAME VARCHAR(128), 
		BEGIN_TIME TIMESTAMP, 
		END_TIME TIMESTAMP, 
		MAX_INVOCATIONS INTEGER, 
		SCHEDULE VARCHAR(1024), 
		OPTIONS VARCHAR(512), 
		REMARKS VARCHAR(254))
	SPECIFIC "SYSPROC"."ADMIN_TASK_UPDATE"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!adminTaskUpdate";

CREATE PROCEDURE "SYSPROC"."ALTER_ROUTINE_PACKAGE" (TYPE CHAR(2), 
		SCHEMA VARCHAR(128), 
		MODULE VARCHAR(128), 
		NAME VARCHAR(128), 
		OPTIONS VARCHAR(1024))
	SPECIFIC "SYSPROC"."ALTER_ROUTINE_3PN"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!alter_routine_3pn";

CREATE PROCEDURE "SYSPROC"."ALTOBJ" (EXEC_MODE VARCHAR(30), 
		SQL_STMT VARCHAR(32672), 
		INOUT ALTER_ID INTEGER, 
		OUT MSG VARCHAR(2048))
	SPECIFIC "SYSPROC"."ALTOBJ"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!altobj";

CREATE PROCEDURE "SYSPROC"."AM_DROP_TASK" (TASK_ID INTEGER)
	SPECIFIC "SYSPROC"."AM_DROP_TASK"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_drop_task";

CREATE PROCEDURE "SYSPROC"."AM_GET_LOCK_CHNS" (AGENT_ID BIGINT, 
		OUT LOCK_CHAINS CLOB(2097152))
	SPECIFIC "SYSPROC"."AM_GET_LOCK_CHNS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_get_lock_chns";

CREATE PROCEDURE "SYSPROC"."AM_GET_LOCK_CHN_TB" (AGENT_ID BIGINT)
	SPECIFIC "SYSPROC"."AM_GET_LOCK_CHN_TB"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_get_lock_chn_tb";

CREATE PROCEDURE "SYSPROC"."AM_GET_LOCK_RPT" (AGENT_ID BIGINT)
	SPECIFIC "SYSPROC"."AM_GET_LOCK_RPT"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 3
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_get_lock_rpt";

CREATE PROCEDURE "SYSPROC"."AM_GET_RPT" (PARTITION INTEGER, 
		REPORT_ID INTEGER, 
		APPL_FILTER CLOB(32768), 
		MAX_NUMBER INTEGER)
	SPECIFIC "SYSPROC"."AM_GET_RPT"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_get_rpt";

CREATE PROCEDURE "SYSPROC"."AM_SAVE_TASK" (MODE CHAR(1), 
		INOUT TASK_ID INTEGER, 
		TASK_NAME VARCHAR(128), 
		APPL_FILTER CLOB(32768), 
		SHOW_LOCK_CHAINS CHAR(1), 
		REPORT_ID VARCHAR(3893))
	SPECIFIC "SYSPROC"."AM_SAVE_TASK"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2am!am_save_task";

CREATE PROCEDURE "SYSPROC"."ANALYZE_LOG_SPACE" (DBPGNAME VARCHAR(128), 
		MAINTBSCHEMA VARCHAR(128), 
		MAINTABLE VARCHAR(128), 
		USETBTYPE SMALLINT, 
		STMGTIMESTAMP VARCHAR(26), 
		ADDDROPOPTION CHAR(1), 
		ADDDROPLIST VARCHAR(6000), 
		PNUMBER VARCHAR(6000), 
		PWEIGHT VARCHAR(6000))
	SPECIFIC "SYSPROC"."ANALYZE_LOG_SPACE"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!analyze_log_space";

CREATE PROCEDURE "SYSPROC"."ASN_ADMIN_UTIL" (CMD VARCHAR(32400), 
		CMDPARMS VARCHAR(32400), 
		CMDOPTIONS VARCHAR(32400), 
		DATAIN_CHAR VARCHAR(32400), 
		DATAIN_BINARY VARCHAR (32400) FOR BIT DATA, 
		CWD VARCHAR(32400), 
		LIBPATH VARCHAR(32400), 
		ROOTPATH VARCHAR(32400), 
		ENV VARCHAR(32400), 
		OUT DATAOUT_CHAR VARCHAR(32400), 
		OUT DATAOUT_BINARY VARCHAR (32400) FOR BIT DATA, 
		OUT RESOPTIONS VARCHAR(32400), 
		OUT MESSAGES VARCHAR(32400), 
		OUT TRACE VARCHAR(32400), 
		OUT ERRORAREA INTEGER, 
		OUT RC INTEGER)
	SPECIFIC "SYSPROC"."ASN_ADMIN_UTIL"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 12
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "asnadmsp!ASNADMIF";

CREATE PROCEDURE "SYSPROC"."AUDIT_ARCHIVE" (DIRECTORY VARCHAR(1024), 
		DBPARTITIONNUM INTEGER)
	SPECIFIC "SYSPROC"."AUDIT_ARCHIVE_SP"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!auditArchiveSP";

CREATE PROCEDURE "SYSPROC"."AUDIT_DELIM_EXTRACT" (DELIMITER VARCHAR(1), 
		TARGET_PATH VARCHAR(1024), 
		SOURCE_PATH VARCHAR(1024), 
		FILE_MASK VARCHAR(1024), 
		EVENT_OPTIONS VARCHAR(1024))
	SPECIFIC "SYSPROC"."AUDIT_DELIM_EXTRACT"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!auditDelExtract";

CREATE PROCEDURE "SYSPROC"."AUTOMAINT_GET_POLICY" (POLICY_TYPE VARCHAR(128), 
		OUT POLICY BLOB(2097152))
	SPECIFIC "SYSPROC"."AUTOMAINT_GET_POLICY"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2AutomaintGetPolicyDocSpLocal";

CREATE PROCEDURE "SYSPROC"."AUTOMAINT_GET_POLICYFILE" (POLICY_TYPE VARCHAR(128), 
		POLICY_FILE_NAME VARCHAR(2048))
	SPECIFIC "SYSPROC"."AUTOMAINT_GET_POLICYFILE"
	MODIFIES SQL DATA
	DETERMINISTIC
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2AutomaintGetPolicyFileSpLocal";

CREATE PROCEDURE "SYSPROC"."AUTOMAINT_SET_POLICY" (POLICY_TYPE VARCHAR(128), 
		POLICY BLOB(2097152))
	SPECIFIC "SYSPROC"."AUTOMAINT_SET_POLICY"
	MODIFIES SQL DATA
	DETERMINISTIC
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2AutomaintSetPolicyDocSpLocal";

CREATE PROCEDURE "SYSPROC"."AUTOMAINT_SET_POLICYFILE" (POLICY_TYPE VARCHAR(128), 
		POLICY_FILE_NAME VARCHAR(2048))
	SPECIFIC "SYSPROC"."AUTOMAINT_SET_POLICYFILE"
	MODIFIES SQL DATA
	DETERMINISTIC
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2AutomaintSetPolicyFileSpLocal";

CREATE PROCEDURE "SYSPROC"."CANCEL_WORK" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."CANCEL_WORK"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!cancel_work";

CREATE PROCEDURE "SYSPROC"."CAPTURE_STORAGEMGMT_INFO" (ROOTTYPE SMALLINT, 
		ROOTSCHEMA VARCHAR(128), 
		ROOTNAME VARCHAR(128))
	SPECIFIC "SYSPROC"."CAPT_STGMGMT_INF"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2stmg!capture_storagemgmt_info";

CREATE PROCEDURE "SYSPROC"."CREATE_SQL_SAMPLE" (SCHEMA_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."CREATE_SQL_SAMPLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2sampl_SQL!main";

CREATE PROCEDURE "SYSPROC"."CREATE_STORAGEMGMT_TABLES" (TSNAME VARCHAR(128))
	SPECIFIC "SYSPROC"."CREATE_STGMGMT_TAB"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2stmg!create_storagemgmt_tables";

CREATE PROCEDURE "SYSPROC"."CREATE_V8_SAMPLE" (SCHEMA_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."CREATE_V8_SAMPLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2sampl_V8!main";

CREATE PROCEDURE "SYSPROC"."CREATE_XML_SAMPLE" (SCHEMA_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."CREATE_XML_SAMPLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2sampl_XML!main";

CREATE PROCEDURE "SYSPROC"."DB2LK_CLEAN_TABLE" (OP_TOKEN INTEGER)
	SPECIFIC "SYSPROC"."DB2LK_CLEAN_TABLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2lkfun!clean_db2look_table";

CREATE PROCEDURE "SYSPROC"."DB2LK_GENERATE_DDL" (COMDSTRING CLOB(2097152), 
		OUT OP_TOKEN INTEGER)
	SPECIFIC "SYSPROC"."DB2LK_GENERATE_DDL"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2lkfun!db2look_generate_ddl";

CREATE PROCEDURE "SYSPROC"."DB2LK_TBLNDEP" (OBJECT_TYPE VARCHAR(20), 
		OBJECT_NAME VARCHAR(128), 
		OBJECT_SCHEMA VARCHAR(128), 
		INOUT OP_TOKEN INTEGER)
	SPECIFIC "SYSPROC"."DB2LK_TBLNDEP"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2lkfun!db2look_sp";

CREATE PROCEDURE "SYSPROC"."DB2LOAD" (VERSION_NUMBER INTEGER, 
		CURSOR_STATEMENT VARCHAR(32672), 
		LOAD_COMMAND VARCHAR(32672), 
		OUT SQLCODE INTEGER, 
		INOUT SQLMESSAGE VARCHAR(2048), 
		OUT ROWS_READ BIGINT, 
		OUT ROWS_SKIPPED BIGINT, 
		OUT ROWS_LOADED BIGINT, 
		OUT ROWS_REJECTED BIGINT, 
		OUT ROWS_DELETED BIGINT, 
		OUT ROWS_COMMITTED BIGINT, 
		OUT ROWS_PART_READ BIGINT, 
		OUT ROWS_PART_REJECTED BIGINT, 
		OUT ROWS_PART_PARTITIONED BIGINT, 
		INOUT MPP_LOAD_SUMMARY VARCHAR(32672))
	SPECIFIC "SYSPROC"."DB2LOAD"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2load!db2load";

CREATE PROCEDURE "SYSPROC"."DBG_ENDSESSIONMANAGER" (HOST VARCHAR(128), 
		PORT INTEGER, 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_ENDSESSIONMGR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_EndSessionManager";

CREATE PROCEDURE "SYSPROC"."DBG_INITIALIZECLIENT" (HOST VARCHAR(128), 
		PORT INTEGER, 
		XMLREQUEST BLOB(32768), 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_INITIALIZECLI"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_InitializeClient";

CREATE PROCEDURE "SYSPROC"."DBG_LOOKUPSESSIONMANAGER" (OUT HOST VARCHAR(128), 
		OUT PORT INTEGER)
	SPECIFIC "SYSPROC"."DBG_LOOKSESSIONMGR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_LookupSessionManager";

CREATE PROCEDURE "SYSPROC"."DBG_PINGSESSIONMANAGER" (HOST VARCHAR(128), 
		PORT INTEGER, 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_PINGSESSIONMGR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_PingSessionManager";

CREATE PROCEDURE "SYSPROC"."DBG_RECVCLIENTREPORTS" (HOST VARCHAR(128), 
		PORT INTEGER, 
		XMLREQUEST BLOB(32768), 
		OUT XMLREPLY BLOB(32768), 
		OUT XMLDATA BLOB(32768), 
		OUT BINDATA BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_RECVCLIREPORTS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_RecvClientReports";

CREATE PROCEDURE "SYSPROC"."DBG_RUNSESSIONMANAGER" (PORT INTEGER, 
		IDLETIMEOUT INTEGER, 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_RUNSESSIONMGR"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_RunSessionManager";

CREATE PROCEDURE "SYSPROC"."DBG_SENDCLIENTCOMMANDS" (HOST VARCHAR(128), 
		PORT INTEGER, 
		XMLREQUEST BLOB(32768), 
		XMLDATA BLOB(32768), 
		BINDATA BLOB(32768), 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_SENDCLICOMMAND"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_SendClientCommands";

CREATE PROCEDURE "SYSPROC"."DBG_SENDCLIENTREQUESTS" (HOST VARCHAR(128), 
		PORT INTEGER, 
		XMLREQUEST BLOB(32768), 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_SENDCLIREQUEST"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_SendClientRequests";

CREATE PROCEDURE "SYSPROC"."DBG_TERMINATECLIENT" (HOST VARCHAR(128), 
		PORT INTEGER, 
		XMLREQUEST BLOB(32768), 
		OUT XMLREPLY BLOB(32768))
	SPECIFIC "SYSPROC"."DBG_TERMINATECLI"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!dbgr_TerminateClient";

CREATE PROCEDURE "SYSPROC"."DESIGN_ADVISOR" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(12288), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."DESIGN_ADVISOR"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 2
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!db2advis_proc";

CREATE PROCEDURE "SYSPROC"."DNET_INSTALLASSEMBLY" (INDIRNAME VARCHAR(1024), 
		INASSEMBLYNAME VARCHAR(1024), 
		INASSEMBLYGUID VARCHAR(1024), 
		INASSEMBLYBIN BLOB(4194304), 
		OUT OUTASSEMBLYEXTERNAL VARCHAR(1024), 
		OUT OUTRESULTCODE INTEGER, 
		OUT OUTRESULTTOKEN VARCHAR(1024))
	SPECIFIC "SYSPROC"."DNET_INSTALLASSEMB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_InstallAssembly";

CREATE PROCEDURE "SYSPROC"."DROP_STORAGEMGMT_TABLES" (DROPSPEC SMALLINT)
	SPECIFIC "SYSPROC"."DROP_STGMGMT_TAB"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2stmg!drop_storagemgmt_tables";

CREATE PROCEDURE "SYSPROC"."EVMON_FORMAT_UE_TO_TABLES" (EVMON_TYPE VARCHAR(128), 
		XSRSCHEMA VARCHAR(128), 
		XSROBJECTNAME VARCHAR(128), 
		XMLSCHEMAFILE VARCHAR(1024), 
		TABSCHEMA VARCHAR(128), 
		TBSP_NAME VARCHAR(128), 
		OPTIONS VARCHAR(1024), 
		COMMIT_COUNT INTEGER, 
		FULLSELECT CLOB(2097152))
	SPECIFIC "SYSPROC"."EVMON_FORMAT_UE_TO_TABLES"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!monEvmonUEToTables";

CREATE PROCEDURE "SYSPROC"."EXDYN_DYNAMIC" (INOUT STATUS INTEGER, 
		TEXT INTEGER, 
		OUT MESSAGE VARCHAR(1000), 
		OUT SECTION INTEGER, 
		OUT SECTIONLEN INTEGER, 
		OUT PROPERTIES BLOB(4096), 
		INOUT RESERVED INTEGER)
	SPECIFIC "SYSPROC"."EXDYN_DYNAMIC"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2exdyn!dynamic";

CREATE PROCEDURE "SYSPROC"."EXDYN_INCBIND" (INOUT STATUS INTEGER, 
		SCHEMA VARCHAR(128), 
		PACKAGE VARCHAR(128), 
		UNIQUE_ID CHAR (8) FOR BIT DATA, 
		SECTNO INTEGER, 
		OUT MESSAGE VARCHAR(1000), 
		OUT SECTION INTEGER, 
		OUT SECTIONLEN INTEGER, 
		INOUT RESERVED INTEGER)
	SPECIFIC "SYSPROC"."EXDYN_INCBIND"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2exdyn!incbind";

CREATE PROCEDURE "SYSPROC"."EXDYN_SQLCACHE" (INOUT STATUS INTEGER, 
		ANCHORID INTEGER, 
		STMTID INTEGER, 
		ENVID INTEGER, 
		VARID INTEGER, 
		OUT MESSAGE VARCHAR(1000), 
		OUT SECTION INTEGER, 
		OUT SECTIONLEN INTEGER, 
		OUT PROPERTIES BLOB(4096), 
		OUT STATEMENT INTEGER, 
		INOUT RESERVED INTEGER)
	SPECIFIC "SYSPROC"."EXDYN_SQLCACHE"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2exdyn!sqlCache";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_FROM_ACTIVITY" (APPL_ID VARCHAR(64), 
		UOW_ID INTEGER, 
		ACTIVITY_ID INTEGER, 
		ACTIVITY_EVMON_NAME VARCHAR(128), 
		INOUT EXPLAIN_SCHEMA VARCHAR(128), 
		OUT EXPLAIN_REQUESTER VARCHAR(128), 
		OUT EXPLAIN_TIME TIMESTAMP, 
		OUT SOURCE_NAME VARCHAR(128), 
		OUT SOURCE_SCHEMA VARCHAR(128), 
		OUT SOURCE_VERSION VARCHAR(64))
	SPECIFIC "SYSPROC"."EXPLAIN_FROM_ACTIVITY"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!explainFromActivity";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_FROM_CATALOG" (PKGSCHEMA VARCHAR(128), 
		PKGNAME VARCHAR(128), 
		PKGVERSION VARCHAR(64), 
		SECTNO SMALLINT, 
		INOUT EXPLAIN_SCHEMA VARCHAR(128), 
		OUT EXPLAIN_REQUESTER VARCHAR(128), 
		OUT EXPLAIN_TIME TIMESTAMP, 
		OUT SOURCE_NAME VARCHAR(128), 
		OUT SOURCE_SCHEMA VARCHAR(128), 
		OUT SOURCE_VERSION VARCHAR(64))
	SPECIFIC "SYSPROC"."EXPLAIN_FROM_CATALOG"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!explainFromCatalog";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_FROM_DATA" (SECTION BLOB(140509184), 
		STMT_TEXT CLOB(2097152), 
		EXECUTABLE_ID VARCHAR (32) FOR BIT DATA, 
		INOUT EXPLAIN_SCHEMA VARCHAR(128), 
		OUT EXPLAIN_REQUESTER VARCHAR(128), 
		OUT EXPLAIN_TIME TIMESTAMP, 
		OUT SOURCE_NAME VARCHAR(128), 
		OUT SOURCE_SCHEMA VARCHAR(128), 
		OUT SOURCE_VERSION VARCHAR(64))
	SPECIFIC "SYSPROC"."EXPLAIN_FROM_DATA"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!explainFromData";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_FROM_SECTION" (EXECUTABLE_ID VARCHAR (32) FOR BIT DATA, 
		SECTION_SOURCE_TYPE CHAR(1), 
		SECTION_SOURCE_NAME VARCHAR(128), 
		MEMBER INTEGER, 
		INOUT EXPLAIN_SCHEMA VARCHAR(128), 
		OUT EXPLAIN_REQUESTER VARCHAR(128), 
		OUT EXPLAIN_TIME TIMESTAMP, 
		OUT SOURCE_NAME VARCHAR(128), 
		OUT SOURCE_SCHEMA VARCHAR(128), 
		OUT SOURCE_VERSION VARCHAR(64))
	SPECIFIC "SYSPROC"."EXPLAIN_FROM_SECTION"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!explainFromSection";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_SQL" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(4096), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."EXPLAIN_SQL"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_explain";

CREATE PROCEDURE "SYSPROC"."EXPLAIN_SQL_HANDLE" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(4096), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(4096), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."EXPLAIN_SQL_HANDLE"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_explain_handle";

CREATE PROCEDURE "SYSPROC"."GENERATE_DISTFILE" (TBSCHEMA VARCHAR(128), 
		TBNAME VARCHAR(128), 
		INOUT FILENAME VARCHAR(255))
	SPECIFIC "SYSPROC"."GEN_DISTFILE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!generate_distfile";

CREATE PROCEDURE "SYSPROC"."GET_CONFIG" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."GET_CONFIG"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_config";

CREATE PROCEDURE "SYSPROC"."GET_DB2_SQLROUTINE_PREOPTS" (OUT PREPOPTIONS VARCHAR(1024), 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."GET_SQLRTN_PREOPTS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_GetPreOpts";

CREATE PROCEDURE "SYSPROC"."GET_DBSIZE_INFO" (OUT SNAPSHOTTIMESTAMP TIMESTAMP, 
		OUT DATABASESIZE BIGINT, 
		OUT DATABASECAPACITY BIGINT, 
		REFRESHWINDOW INTEGER)
	SPECIFIC "SYSPROC"."GET_DBSIZE_INFO"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2stmg!get_dbsize_info";

CREATE PROCEDURE "SYSPROC"."GET_DB_CONFIG" ()
	SPECIFIC "SYSPROC"."GET_DB_CONFIG"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!get_db_config";

CREATE PROCEDURE "SYSPROC"."GET_MESSAGE" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."GET_MESSAGE"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_message";

CREATE PROCEDURE "SYSPROC"."GET_PLAN_HINT" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."GET_PLAN_HINT"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 2
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_plan_hint";

CREATE PROCEDURE "SYSPROC"."GET_SWRD_SETTINGS" (DBPGNAME VARCHAR(128), 
		MATCHINGSPEC SMALLINT, 
		OUT REDISTMETHOD SMALLINT, 
		OUT PMAPFILE VARCHAR(255), 
		OUT DISTFILE VARCHAR(255), 
		OUT STEPSIZE BIGINT, 
		OUT TOTALSTEPS SMALLINT, 
		OUT STAGESIZE SMALLINT, 
		OUT NEXTSTEP SMALLINT, 
		OUT PROCESSSTATE SMALLINT, 
		OUT PNUMBER VARCHAR(6000), 
		OUT PWEIGHT VARCHAR(6000))
	SPECIFIC "SYSPROC"."GET_SWRD_SETTINGS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!get_swrd_settings";

CREATE PROCEDURE "SYSPROC"."GET_SYSTEM_INFO" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."GET_SYSTEM_INFO"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!get_system_info";

CREATE PROCEDURE "SYSPROC"."GET_WRAP_CFG_C" (WRAPPERID VARCHAR(128), 
		CLIENTLOCALE VARCHAR(128), 
		OUT SERVERPLATFORM VARCHAR(128), 
		OUT TRACELOG VARCHAR(2000), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."GET_WRAP_CFG_C"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!getWrapperXMLFiles";

CREATE PROCEDURE "SYSPROC"."GET_WRAP_CFG_C2" (WRAPPERID VARCHAR(128), 
		CLIENTLOCALE VARCHAR(128), 
		OUT SERVERPLATFORM VARCHAR(128), 
		OUT TRACELOG VARCHAR(2000))
	SPECIFIC "SYSPROC"."GET_WRAP_CFG_C2"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!getWrapperXMLFiles2";

CREATE PROCEDURE "SYSPROC"."HASNICKNAMECHANGED" (INSERVERNAME VARCHAR(128), 
		INTABSCHEMA VARCHAR(128), 
		INTABNAME VARCHAR(128), 
		INTIMESTAMP TIMESTAMP, 
		OUT OUTYESNO CHAR(1), 
		OUT OUTSQLCODE INTEGER)
	SPECIFIC "SYSPROC"."HASNICKNAMECHANGED"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!HasNicknameChanged";

CREATE PROCEDURE "SYSPROC"."HEALTH_HI_REC" (SCHEMA_VERSION INTEGER, 
		INDICATOR_ID INTEGER, 
		DBNAME VARCHAR(255), 
		OBJTYPE INTEGER, 
		OBJNAME VARCHAR(255), 
		DBPARTITIONNUM INTEGER, 
		CLIENT_LOCALE VARCHAR(33), 
		OUT REC_DOCUMENT BLOB(2097152))
	SPECIFIC "SYSPROC"."HEALTH_HI_REC"
	NO SQL
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!health_hi_rec";

CREATE PROCEDURE "SYSPROC"."ITMAGENT_SET_CONFIG" (HOST VARCHAR(256), 
		PORT INTEGER, 
		OPTIONS VARCHAR(2048), 
		ACTION SMALLINT, 
		OUT SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."ITMAGENT_SET_CONFIG"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!itmagentSetConfig";

CREATE PROCEDURE "SYSPROC"."LIST_SRVR_NODES" (WRAPPERNAME VARCHAR(128), 
		SERVERTYPE VARCHAR(128), 
		SERVERVERSION VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_SRVR_NODES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_srvr_nodes";

CREATE PROCEDURE "SYSPROC"."LIST_SRVR_OPTIONS" (WRAPPERNAME VARCHAR(128), 
		SERVERTYPE VARCHAR(128), 
		SERVERVERSION VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_SRVR_OPTIONS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_srvr_opts";

CREATE PROCEDURE "SYSPROC"."LIST_SRVR_OPTVALS" (WRAPPERNAME VARCHAR(128), 
		SERVERTYPE VARCHAR(128), 
		SERVERVERSION VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_SRVR_OPTVALS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_srvr_optvals";

CREATE PROCEDURE "SYSPROC"."LIST_SRVR_TYPES" (WRAPPERNAME VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_SRVR_TYPES"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_srvr_types";

CREATE PROCEDURE "SYSPROC"."LIST_SRVR_VERSIONS" (WRAPPERNAME VARCHAR(128), 
		SERVERTYPE VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_SRVR_VERSIONS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_srvr_vrsns";

CREATE PROCEDURE "SYSPROC"."LIST_WRAPPERS" (OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_WRAPPERS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_wrappers";

CREATE PROCEDURE "SYSPROC"."LIST_WRAP_OPTIONS" (WRAPPERNAME VARCHAR(128), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."LIST_WRAP_OPTIONS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!list_wrap_opts";

CREATE PROCEDURE "SYSPROC"."NICKNAMEINFO" (INSERVERNAME VARCHAR(128), 
		INTABSCHEMA VARCHAR(128), 
		INTABNAME VARCHAR(128), 
		INRETRIEVETYPE INTEGER, 
		OUT OUTWRAPPERNAME VARCHAR(128), 
		OUT OUTSERVERTYPE VARCHAR(128), 
		OUT OUTSERVERVERSION VARCHAR(128), 
		OUT OUTSERVERNAME VARCHAR(128), 
		OUT OUTSERVERNODE VARCHAR(128), 
		OUT OUTREMOTESCHEMA VARCHAR(128), 
		OUT OUTREMOTETABLE VARCHAR(128), 
		OUT OUTREMOTETYPE CHAR(1), 
		OUT OUTREMOTESTAMP TIMESTAMP, 
		OUT OUTREMOTESTATSTIME TIMESTAMP, 
		OUT OUTSQLCODE INTEGER)
	SPECIFIC "SYSPROC"."NICKNAMEINFO_EXTENDED"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!NicknameInfo_extended";

CREATE PROCEDURE "SYSPROC"."NICKNAMEINFO" (INSERVERNAME VARCHAR(128), 
		INTABSCHEMA VARCHAR(128), 
		INTABNAME VARCHAR(128), 
		OUT OUTWRAPPERNAME VARCHAR(128), 
		OUT OUTSERVERTYPE VARCHAR(128), 
		OUT OUTSERVERVERSION VARCHAR(128), 
		OUT OUTSERVERNAME VARCHAR(128), 
		OUT OUTSERVERNODE VARCHAR(128), 
		OUT OUTREMOTESCHEMA VARCHAR(128), 
		OUT OUTREMOTETABLE VARCHAR(128), 
		OUT OUTREMOTETYPE CHAR(1), 
		OUT OUTREMOTESTAMP TIMESTAMP, 
		OUT OUTSQLCODE INTEGER)
	SPECIFIC "SYSPROC"."NICKNAMEINFO"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!NicknameInfo";

CREATE PROCEDURE "SYSPROC"."NNSTAT" (SERVER VARCHAR(128), 
		SCHEMA VARCHAR(128), 
		NICKNAME VARCHAR(128), 
		COLNAMES CLOB(2097152), 
		INDEXNAMES CLOB(2097152), 
		METHOD SMALLINT, 
		LOG_FILE_PATH VARCHAR(1000), 
		OUT OUT_TRACE VARCHAR(2000))
	SPECIFIC "SYSPROC"."NNSTAT_EXTENDED"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dsproc!nnstat_extended";

CREATE PROCEDURE "SYSPROC"."NNSTAT" (SERVER VARCHAR(128), 
		SCHEMA VARCHAR(128), 
		NICKNAME VARCHAR(128), 
		LOG_FILE_PATH VARCHAR(1000), 
		OUT OUT_TRACE VARCHAR(2000), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."NNSTAT"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dsproc!nnStat";

CREATE PROCEDURE "SYSPROC"."ODBC_DISCOVERY" (SERVERNAME VARCHAR(128), 
		USERNAME VARCHAR(128), 
		AUTHENTICATION VARCHAR(128), 
		CATALOGNAMEOPERATOR VARCHAR(128), 
		CATALOGNAMEPATTERN VARCHAR(128), 
		SCHEMANAMEOPERATOR VARCHAR(128), 
		SCHEMANAMEPATTERN VARCHAR(128), 
		TABLENAMEOPERATOR VARCHAR(128), 
		TABLENAMEPATTERN VARCHAR(128), 
		OUT SQLCODE INTEGER, 
		OUT SQLSTATE VARCHAR(5), 
		OUT MESSAGETEXT VARCHAR(1024))
	SPECIFIC "SYSPROC"."ODBC_DISCOVERY"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!odbc_discovery";

CREATE PROCEDURE "SYSPROC"."ODBC_DISCOVERY2" (SERVERNAME VARCHAR(128), 
		USERNAME VARCHAR(128), 
		AUTHENTICATION VARCHAR(128), 
		CATALOGNAMEOPERATOR VARCHAR(128), 
		CATALOGNAMEPATTERN VARCHAR(128), 
		SCHEMANAMEOPERATOR VARCHAR(128), 
		SCHEMANAMEPATTERN VARCHAR(128), 
		TABLENAMEOPERATOR VARCHAR(128), 
		TABLENAMEPATTERN VARCHAR(128))
	SPECIFIC "SYSPROC"."ODBC_DISCOVERY2"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!odbc_discovery2";

CREATE PROCEDURE "SYSPROC"."ODBC_DISCOVERY2_32" (SERVERNAME VARCHAR(128), 
		USERNAME VARCHAR(128), 
		AUTHENTICATION VARCHAR(128), 
		CATALOGNAMEOPERATOR VARCHAR(128), 
		CATALOGNAMEPATTERN VARCHAR(128), 
		SCHEMANAMEOPERATOR VARCHAR(128), 
		SCHEMANAMEPATTERN VARCHAR(128), 
		TABLENAMEOPERATOR VARCHAR(128), 
		TABLENAMEPATTERN VARCHAR(128))
	SPECIFIC "SYSPROC"."ODBC_DISCOVERY2_32"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc32!odbc_discovery2";

CREATE PROCEDURE "SYSPROC"."ODBC_DISCOVERY_32" (SERVERNAME VARCHAR(128), 
		USERNAME VARCHAR(128), 
		AUTHENTICATION VARCHAR(128), 
		CATALOGNAMEOPERATOR VARCHAR(128), 
		CATALOGNAMEPATTERN VARCHAR(128), 
		SCHEMANAMEOPERATOR VARCHAR(128), 
		SCHEMANAMEPATTERN VARCHAR(128), 
		TABLENAMEOPERATOR VARCHAR(128), 
		TABLENAMEPATTERN VARCHAR(128), 
		OUT SQLCODE INTEGER, 
		OUT SQLSTATE VARCHAR(5), 
		OUT MESSAGETEXT VARCHAR(1024))
	SPECIFIC "SYSPROC"."ODBC_DISCOVERY_32"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc32!odbc_discovery";

CREATE PROCEDURE "SYSPROC"."POLICY_INSTALL" (ACTION CHAR(1), 
		MED VARCHAR(128), 
		DECISION VARCHAR(128), 
		NAME VARCHAR(128), 
		POLICYDOC BLOB(2097152))
	SPECIFIC "SYSPROC"."POLICY_INSTALL"
	MODIFIES SQL DATA
	DETERMINISTIC
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2PolicyInstallSp";

CREATE PROCEDURE "SYSPROC"."POLICY_INSTALLOC" (ACTION CHAR(1), 
		MED VARCHAR(128), 
		DECISION VARCHAR(128), 
		NAME VARCHAR(128), 
		FILENAME VARCHAR(2048))
	SPECIFIC "SYSPROC"."POLICY_INSTALLOC"
	MODIFIES SQL DATA
	DETERMINISTIC
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2policy!db2PolicyInstallSpLocal";

CREATE PROCEDURE "SYSPROC"."POLICY_RETRIEVE" (MED VARCHAR(128), 
		DECISION VARCHAR(128), 
		NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."POLICY_RETRIEVE"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2policy!db2PolicyRetrieve";

CREATE PROCEDURE "SYSPROC"."PSMD_CLEAR_SESSION" (SESSIONID DOUBLE, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_CLEAR_SESSION"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_ClearSession";

CREATE PROCEDURE "SYSPROC"."PSMD_GET_LEVEL" (REQUESTXML VARCHAR(4000), 
		OUT REPLYXML VARCHAR(4000))
	SPECIFIC "SYSPROC"."PSMD_GET_LEVEL"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_GetLevel";

CREATE PROCEDURE "SYSPROC"."PSMD_GET_REPORT" (SESSIONID DOUBLE, 
		OUT XMLDATA LONG VARCHAR, 
		OUT BINDATA LONG VARCHAR FOR BIT DATA, 
		WAITTIME INTEGER, 
		OUT MOREDATA INTEGER, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_GET_REPORT"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_GetReport";

CREATE PROCEDURE "SYSPROC"."PSMD_INIT_SESSION" (SESSIONID DOUBLE, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_INIT_SESSION"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_Initialize";

CREATE PROCEDURE "SYSPROC"."PSMD_PUT_COMMAND" (SESSIONID DOUBLE, 
		XMLDATA LONG VARCHAR, 
		BINDATA LONG VARCHAR FOR BIT DATA, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_PUT_COMMAND"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_PutCommand";

CREATE PROCEDURE "SYSPROC"."PSMD_SET_COMPILEMODE" (COMPILEMODE INTEGER)
	SPECIFIC "SYSPROC"."PSMD_SET_COMPMODE"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_CompileForDebug";

CREATE PROCEDURE "SYSPROC"."PSMD_SET_DEBUGINFO" (DEBUGINFO VARCHAR(255), 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_SET_DEBUGINFO"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_SetDebugInfo";

CREATE PROCEDURE "SYSPROC"."PSMD_SET_SESSION" (SESSIONID DOUBLE, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_SET_SESSION"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_SetSession";

CREATE PROCEDURE "SYSPROC"."PSMD_TERM_SESSION" (SESSIONID DOUBLE, 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."PSMD_TERM_SESSION"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_Terminate";

CREATE PROCEDURE "SYSPROC"."REBIND_ROUTINE_PACKAGE" (TYPE CHAR(2), 
		NAME VARCHAR(386), 
		OPTIONS VARCHAR(1024))
	SPECIFIC "SYSPROC"."REBIND_ROUTINE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!rebind_routine";

CREATE PROCEDURE "SYSPROC"."REBIND_ROUTINE_PACKAGE" (TYPE CHAR(2), 
		SCHEMA VARCHAR(128), 
		MODULE VARCHAR(128), 
		NAME VARCHAR(128), 
		OPTIONS VARCHAR(1024))
	SPECIFIC "SYSPROC"."REBIND_ROUTINE_3PN"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2udp!rebind_routine_3pn";

CREATE PROCEDURE "SYSPROC"."REMOTE_QUERY" (SERVERNAME VARCHAR(128), 
		SCHEMAOPERATOR VARCHAR(16), 
		SCHEMAPATTERN VARCHAR(100), 
		TABLEOPERATOR VARCHAR(16), 
		TABLEPATTERN VARCHAR(100), 
		PERFORMCOUNT SMALLINT, 
		OUT REMOTESQL VARCHAR(300), 
		OUT OUT_SQLCODE INTEGER)
	SPECIFIC "SYSPROC"."REMOTE_QUERY"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!remote_query";

CREATE PROCEDURE "SYSPROC"."REMOTE_QUERY2" (SERVERNAME VARCHAR(128), 
		SCHEMAOPERATOR VARCHAR(16), 
		SCHEMAPATTERN VARCHAR(100), 
		TABLEOPERATOR VARCHAR(16), 
		TABLEPATTERN VARCHAR(100), 
		PERFORMCOUNT SMALLINT, 
		OUT REMOTESQL VARCHAR(300))
	SPECIFIC "SYSPROC"."REMOTE_QUERY2"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dsproc!remote_query2";

CREATE PROCEDURE "SYSPROC"."REORGCHK_IX_STATS" (SCOPE CHAR(1), 
		CRITERIA VARCHAR(261))
	SPECIFIC "SYSPROC"."REORGCHK_IX_STATS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!reorgchk_ix_stats";

CREATE PROCEDURE "SYSPROC"."REORGCHK_TB_STATS" (SCOPE CHAR(1), 
		CRITERIA VARCHAR(261))
	SPECIFIC "SYSPROC"."REORGCHK_TB_STATS"
	MODIFIES SQL DATA
	DYNAMIC RESULT SETS 1
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!reorgchk_tb_stats";

CREATE PROCEDURE "SYSPROC"."SET_CONFIG" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."SET_CONFIG"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!set_config";

CREATE PROCEDURE "SYSPROC"."SET_DB2_SQLROUTINE_PREOPTS" (PREPOPTIONS VARCHAR(1024), 
		OUT RESULT INTEGER)
	SPECIFIC "SYSPROC"."SET_SQLRTN_PREOPTS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE GENERAL
	EXTERNAL NAME "db2psmdr!sdbg_SetPreOpts";

CREATE PROCEDURE "SYSPROC"."SET_PLAN_HINT" (INOUT MAJOR_VERSION INTEGER, 
		INOUT MINOR_VERSION INTEGER, 
		REQUESTED_LOCALE VARCHAR(33), 
		XML_INPUT BLOB(33554432), 
		XML_FILTER BLOB(4096), 
		OUT XML_OUTPUT BLOB(33554432), 
		OUT XML_MESSAGE BLOB(65536))
	SPECIFIC "SYSPROC"."SET_PLAN_HINT"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2cadm!set_plan_hint";

CREATE PROCEDURE "SYSPROC"."SET_ROUTINE_OPTS" (OPTIONS VARCHAR(1024))
	SPECIFIC "SYSPROC"."SET_ROUTINE_OPTS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2pvm!set_options";

CREATE PROCEDURE "SYSPROC"."SET_SWRD_SETTINGS" (DBPGNAME VARCHAR(128), 
		OVERWRITESPEC SMALLINT, 
		REDISTMETHOD SMALLINT, 
		PMAPFILE VARCHAR(255), 
		DISTFILE VARCHAR(255), 
		STEPSIZE BIGINT, 
		TOTALSTEPS SMALLINT, 
		STAGESIZE SMALLINT, 
		NEXTSTEP SMALLINT, 
		PROCESSSTATE SMALLINT, 
		PNUMBER VARCHAR(6000), 
		PWEIGHT VARCHAR(6000))
	SPECIFIC "SYSPROC"."SET_SWRD_SETTINGS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!set_swrd_settings";

CREATE PROCEDURE "SYSPROC"."SNAPSHOT_FILEW" (REQUESTTYPE SMALLINT, 
		DBNAME VARCHAR(128), 
		PARTITIONNUM SMALLINT)
	SPECIFIC "SYSPROC"."SNAPSHOT_FILEW"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!snapshot_filew";

CREATE PROCEDURE "SYSPROC"."SNAP_WRITE_FILE" (REQUEST_TYPE VARCHAR(32), 
		DBNAME VARCHAR(128), 
		DBPARTITIONNUM INTEGER)
	SPECIFIC "SYSPROC"."SNAP_WRITE_FILE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2monudf!snap_write_file";

CREATE PROCEDURE "SYSPROC"."STEPWISE_REDISTRIBUTE_DBPG" (DBPGNAME VARCHAR(128), 
		STARTINGPOINT SMALLINT, 
		NUMSTEPS SMALLINT)
	SPECIFIC "SYSPROC"."STEP_REDIST_DBPG"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE DB2SQL
	EXTERNAL NAME "db2dbappext!stepwise_redistribute_dbpg";

CREATE PROCEDURE "SYSPROC"."SYSINSTALLOBJECTS" (TOOL_NAME VARCHAR(128), 
		ACTION CHAR(1), 
		TABLESPACE_NAME VARCHAR(128), 
		SCHEMA_NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."SYSINSTALLOBJECTS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!sysinstallobjects";

CREATE PROCEDURE "SYSPROC"."SYSINSTALLROUTINES" ()
	SPECIFIC "SYSPROC"."SYSINSTALLROUTINES"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "db2dbroutext!sysinstallroutines";

CREATE PROCEDURE "SYSPROC"."SYSTS_ADMIN_CMD" (CMD VARCHAR(32000), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_ADMIN_CMD"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp";

CREATE PROCEDURE "SYSPROC"."SYSTS_ALTER" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		ALTER_OPTIONS VARCHAR(32000), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_ALTER"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_alter";

CREATE PROCEDURE "SYSPROC"."SYSTS_CLEAR_COMMANDLOCKS" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_CLEAR_COMMANDLOCKS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_clearcmdlocks";

CREATE PROCEDURE "SYSPROC"."SYSTS_CLEAR_EVENTS" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_CLEAR_EVENTS"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_clearevents";

CREATE PROCEDURE "SYSPROC"."SYSTS_CREATE" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		TEXT_SOURCE VARCHAR(1024), 
		OPTIONS VARCHAR(32000), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_CREATE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_create";

CREATE PROCEDURE "SYSPROC"."SYSTS_DISABLE" (OPTIONS VARCHAR(128), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_DISABLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_disable";

CREATE PROCEDURE "SYSPROC"."SYSTS_DROP" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_DROP"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_drop";

CREATE PROCEDURE "SYSPROC"."SYSTS_ENABLE" (MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_ENABLE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_enable";

CREATE PROCEDURE "SYSPROC"."SYSTS_UPDATE" (INDEX_SCHEMA VARCHAR(128), 
		INDEX_NAME VARCHAR(128), 
		UPDATE_OPTIONS VARCHAR(32000), 
		MESSAGE_LOCALE VARCHAR(33), 
		OUT MESSAGE VARCHAR(32000))
	SPECIFIC "SYSPROC"."SYSTS_UPDATE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE GNRLNULL
	EXTERNAL NAME "ciespadm!ciesrvsp_update";

CREATE PROCEDURE "SYSPROC"."WLM_CANCEL_ACTIVITY" (APPLICATION_HANDLE BIGINT, 
		UOW_ID INTEGER, 
		ACTIVITY_ID INTEGER)
	SPECIFIC "SYSPROC"."WLM_CANCEL_ACTIVITY"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!wlmCancelActivity";

CREATE PROCEDURE "SYSPROC"."WLM_CAPTURE_ACTIVITY_IN_PROGRESS" (APPLICATION_HANDLE BIGINT, 
		UOW_ID INTEGER, 
		ACTIVITY_ID INTEGER)
	SPECIFIC "SYSPROC"."WLM_CAPTURE_ACTIVITY_IN_PROGRESS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!wlmCaptureActivityInProgress";

CREATE PROCEDURE "SYSPROC"."WLM_COLLECT_STATS" ()
	SPECIFIC "SYSPROC"."WLM_COLLECT_STATS"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!wlmCollectAndResetStats";

CREATE PROCEDURE "SYSPROC"."WLM_COLLECT_STATS" (WAIT CHAR(1), 
		OUT STATISTICS_TIMESTAMP TIMESTAMP)
	SPECIFIC "SYSPROC"."WLM_COLLECT_STATS_WAIT"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!wlmCollectAndResetStatsWait";

CREATE PROCEDURE "SYSPROC"."WLM_SET_CLIENT_INFO" (CLIENT_USERID VARCHAR(255), 
		CLIENT_WRKSTNNAME VARCHAR(255), 
		CLIENT_APPLNAME VARCHAR(255), 
		CLIENT_ACCTSTR VARCHAR(200), 
		CLIENT_WORKLOAD VARCHAR(255))
	SPECIFIC "SYSPROC"."SET_CLIENT_INFO"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbroutext!wlmSetClientInfo";

CREATE PROCEDURE "SYSPROC"."WLM_SET_CONN_ENV" (APPLICATION_HANDLE BIGINT, 
		SETTINGS CLOB(8192))
	SPECIFIC "SYSPROC"."WLM_SET_CONN_ENV"
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2dbrouttrusted!wlmSetConnEnv";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(1048576), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML100MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(104857600), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML100MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML10MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(10485760), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML10MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML1GB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(1073741824), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML1GB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML1_5GB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(1610612736), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML1_5GB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML25MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(26214400), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML25MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML2GB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(2147483647), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML2GB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML500MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(524288000), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML500MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML50MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(52428800), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML50MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXML75MB" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		XMLDOC BLOB(78643200), 
		DOCUMENTID VARCHAR(1024), 
		VALIDATION INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		RESERVED3 INTEGER)
	SPECIFIC "SYSPROC"."XDBDECOMPXML75MB"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromBlob";

CREATE PROCEDURE "SYSPROC"."XDBDECOMPXMLFROMFILELIST" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		RESERVED BLOB(128), 
		FILELIST BLOB(131072), 
		VALIDATION INTEGER, 
		COMMITCOUNT INTEGER, 
		ALLOWACCESS INTEGER, 
		RESERVED2 BLOB(65536), 
		RESERVED3 BLOB(65536), 
		RESERVED4 INTEGER, 
		OUT TOTALDOCS INTEGER, 
		OUT NUMDOCSDECOMPOSED INTEGER, 
		OUT RESULTREPORT BLOB(1048576))
	SPECIFIC "SYSPROC"."XDBDECOMPXMLFROMFILELIST"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromFileList";

CREATE PROCEDURE "SYSPROC"."XDB_DECOMP_XML_FROM_QUERY" (RSCHEMA VARCHAR(128), 
		XMLSCHEMANAME VARCHAR(128), 
		QUERY CLOB(1048576), 
		VALIDATION INTEGER, 
		COMMITCOUNT INTEGER, 
		ALLOWACCESS INTEGER, 
		RESERVED BLOB(65536), 
		RESERVED2 BLOB(65536), 
		CONTINUEONERROR INTEGER, 
		OUT TOTALDOCS INTEGER, 
		OUT NUMDOCSDECOMPOSED INTEGER, 
		OUT RESULTREPORT BLOB(104857600))
	SPECIFIC "SYSPROC"."XDB_DECOMP_XML_FROM_QUERY"
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2decomp!xdbDecompXMLFromQuery";

CREATE PROCEDURE "SYSPROC"."XSR_ADDSCHEMADOC" (RSCHEMA VARCHAR(128), 
		NAME VARCHAR(128), 
		SCHEMALOCATION VARCHAR(1000), 
		CONTENT BLOB(31457280), 
		DOCPROPERTIES BLOB(5242880))
	SPECIFIC "SYSPROC"."XSR_ADDSCHEMADOC"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!addXMLSchemaDocument";

CREATE PROCEDURE "SYSPROC"."XSR_COMPLETE" (RSCHEMA VARCHAR(128), 
		NAME VARCHAR(128), 
		SCHEMAPROPERTIES BLOB(5242880), 
		SHREDDING INTEGER)
	SPECIFIC "SYSPROC"."XSR_COMPLETE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!completeXMLSchema";

CREATE PROCEDURE "SYSPROC"."XSR_DTD" (INOUT RSCHEMA VARCHAR(128), 
		INOUT NAME VARCHAR(128), 
		SYSTEMID VARCHAR(1000), 
		PUBLICID VARCHAR(1000), 
		CONTENT BLOB(5242880))
	SPECIFIC "SYSPROC"."XSR_DTD"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!registerDTD";

CREATE PROCEDURE "SYSPROC"."XSR_EXTENTITY" (INOUT RSCHEMA VARCHAR(128), 
		INOUT NAME VARCHAR(128), 
		SYSTEMID VARCHAR(1000), 
		PUBLICID VARCHAR(1000), 
		CONTENT BLOB(5242880))
	SPECIFIC "SYSPROC"."XSR_EXTENTITY"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!registerExtEntity";

CREATE PROCEDURE "SYSPROC"."XSR_GET_PARSING_DIAGNOSTICS" (INSTANCE BLOB(31457280), 
		RSCHEMA VARCHAR(128), 
		NAME VARCHAR(128), 
		SCHEMALOCATION VARCHAR(1000), 
		IMPLICITVALIDATION INTEGER, 
		OUT ERRORDIALOG VARCHAR(32000), 
		OUT ERRORCOUNT INTEGER)
	SPECIFIC "SYSPROC"."XSR_GET_PARSING_DIAGNOSTICS"
	READS SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!get_parsing_diagnostics";

CREATE PROCEDURE "SYSPROC"."XSR_REGISTER" (INOUT RSCHEMA VARCHAR(128), 
		INOUT NAME VARCHAR(128), 
		SCHEMALOCATION VARCHAR(1000), 
		CONTENT BLOB(31457280), 
		DOCPROPERTIES BLOB(5242880))
	SPECIFIC "SYSPROC"."XSR_REGISTER"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!registerXMLSchema";

CREATE PROCEDURE "SYSPROC"."XSR_REMOVE" (RSCHEMA VARCHAR(128), 
		NAME VARCHAR(128))
	SPECIFIC "SYSPROC"."XSR_REMOVE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED NOT THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!removeXMLSchema";

CREATE PROCEDURE "SYSPROC"."XSR_UPDATE" (RSCHEMA1 VARCHAR(128), 
		NAME1 VARCHAR(128), 
		RSCHEMA2 VARCHAR(128), 
		NAME2 VARCHAR(128), 
		DELETED INTEGER)
	SPECIFIC "SYSPROC"."XSR_UPDATE"
	MODIFIES SQL DATA
	LANGUAGE C
	FENCED THREADSAFE
	PARAMETER STYLE SQL
	EXTERNAL NAME "db2xsr!updateXMLSchema";

CREATE PROCEDURE SYSIBMADM.RAISE_APPLICATION_ERROR( num INTEGER, msg VARCHAR(2000), keeperrorstack BOOLEAN )       SPECIFIC RAISE_APPLICATION_ERROR_2       LANGUAGE SQL       BEGIN         IF keeperrorstack IS NULL OR keeperrorstack = true THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'RAISE_APPLICATION_ERROR', 'KEEPERRORSTACK' );         END IF;         CALL SYSIBMADM.RAISE_APPLICATION_ERROR( num, msg );       END;

CREATE PROCEDURE bonus_increase                            (IN p_bonusFactor DECIMAL (3,2),                              IN p_bonusMaxSumForDept DECIMAL (9,2),                              OUT p_deptsWithoutNewBonuses VARCHAR(255),                              OUT p_countDeptsViewed INTEGER,                              OUT p_countDeptsBonusChanged INTEGER,                              OUT p_errorMsg VARCHAR(255)) SPECIFIC BONUS_INCREASE
LANGUAGE SQL
DYNAMIC RESULT SETS 1

BEGIN
-- -------------------------------------------------------------------------------------
-- Routine type:  SQL stored procedure
-- Routine name:  bonus_increase
--
-- Purpose:  This procedure takes in a multiplier value that is used to update
--           employee bonus values.  The employee bonus updates are done department
--           by department.  Updated employee bonus values are only committed if the
--           sum of the bonuses for a department does not exceed the threshold amount
--           specified by another input parameter.  A result is returned listing, by
--           department, employee numbers and currently set bonus values.
--
-- Features shown:
--           - IN and OUT parameters
--           - Variable declaration and setting
--           - Condition handler declaration and use
--           - Use of CURSOR WITH HOLD
--           - Use of SAVEPOINT and ROLLBACK to SAVEPOINT
--           - Returning of a result set to the caller
--           - Use of a WHILE loop control-statement
--           - Use of IF/ELSE statement
--           - Use of labels and GOTO statement
--           - Use of RETURN statement
--
-- Parameters:
-- IN  p_bonusFactor:      Constant multiple by which employee bonuses are updated
-- IN  p_bonusMaxSumForDept:    Maximum amount for departmental bonuses without review
-- OUT p_deptsWithoutNewBonuses:  Comma delimited list of departments that require
--                                   a manual setting and review of bonus amounts
-- OUT p_countDeptsViewed:     Number of departments processed
-- OUT p_countDeptsBonusChanged:  Number of departments for which bonuses were set
-- OUT p_errorMsg:       Error message string
-- --------------------------------------------------------------------------------------
    DECLARE v_dept, v_actdept CHAR(3);
    DECLARE v_bonus, v_deptbonus, v_newbonus DECIMAL(9,2);
    DECLARE v_empno CHAR(6);
    DECLARE v_atend SMALLINT DEFAULT 0;

    -- Cursor that lists employee numbers and bonuses ordered by department
    -- This cursor is declared as WITH HOLD so that on rollbacks it remains
    -- open.  It is declared as FOR UPDATE OF bonus, so that the employee
    -- bonus column field can be updated as the cursor iterates through the rows.

    DECLARE cSales CURSOR WITH HOLD FOR
          SELECT workdept, bonus, empno FROM employee ORDER BY workdept
      FOR UPDATE OF bonus;

    -- This cursor, declared with WITH RETURN TO CALLER, is used to return
    -- a result set to the caller when this procedure returns.  The result
    -- set contains a list of the employees and their bonus values ordered
    -- by the department numbers.

    DECLARE cEmpBonuses CURSOR WITH RETURN TO CALLER FOR
          SELECT workdept, empno, bonus FROM employee ORDER BY workdept;

    -- This continue handler is used to catch the NOT FOUND error
    -- associated with the end of the iteration over the cursor cSales.
    -- It is used to set v_atend which flags the end of the WHILE loop.

     DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_atend=1;

    -- This continue handler is used to catch any numeric overflows

    DECLARE EXIT HANDLER FOR SQLSTATE '22003'
    BEGIN
      SET p_errorMsg = 'SQLSTATE 22003 - Numeric overflow occurred setting bonus';
    END;

    DECLARE EXIT HANDLER FOR SQLEXCEPTION SET v_atend=1;

    -- Initialize local variables

    SET p_errorMsg = '';
    SET p_deptsWithoutNewBonuses = '';
    SET p_countDeptsViewed = 0;
    SET p_countDeptsBonusChanged = 0;

    -- Check input parameter is valid

    IF (p_bonusFactor < 1 OR p_bonusFactor > 2) THEN
      SET p_errorMsg = 'E01 Checking parameter p_bonusFactor, validation';
      GOTO error_found;
    END IF;

    OPEN cSales;

    FETCH cSales INTO v_dept, v_bonus, v_empno;

    nextdept:
        IF v_atend = 0 THEN

            -- This savepoint is used to rollback the bonuses assigned to employees if
            -- the sum of bonuses for a department exceeds a threshold amount

            SAVEPOINT svpt_bonus ON ROLLBACK RETAIN CURSORS;

            SET v_actdept = v_dept;
            SET v_deptbonus = 0;

            WHILE ( v_actdept = v_dept ) AND ( v_atend = 0 ) DO
                    SET v_newbonus = v_bonus * p_bonusFactor;
                    UPDATE employee SET bonus = v_newbonus WHERE empno = v_empno;
                    SET v_deptbonus = v_deptbonus + v_newbonus;
                    FETCH cSales INTO v_dept, v_bonus, v_empno;
            END WHILE;

            SET p_countDeptsViewed = p_countDeptsViewed + 1;

            IF v_deptbonus <= p_bonusMaxSumForDept THEN
                SET p_countDeptsBonusChanged = p_countDeptsBonusChanged + 1;
                COMMIT;
            ELSE
                     ROLLBACK TO SAVEPOINT svpt_bonus;
                     RELEASE SAVEPOINT svpt_bonus;
                     SET p_deptsWithoutNewBonuses =
                                     (CASE WHEN p_deptsWithoutNewBonuses = ''
                                           THEN v_actdept
                                      ELSE
                                           p_deptsWithoutNewBonuses || ', ' || v_actdept
                                      END);
            END IF;
            GOTO nextdept;
        END IF;

    OPEN cEmpBonuses;

    RETURN 0;

error_found:
    SET p_errorMsg = p_errorMsg || ' failed.';
    RETURN -1;

END;

CREATE MODULE "SYSIBMADM"."DBMS_ALERT";

CREATE MODULE "SYSIBMADM"."DBMS_DDL";

CREATE MODULE "SYSIBMADM"."DBMS_JOB";

CREATE MODULE "SYSIBMADM"."DBMS_LOB";

CREATE MODULE "SYSIBMADM"."DBMS_OUTPUT";

CREATE MODULE "SYSIBMADM"."DBMS_PIPE";

CREATE MODULE "SYSIBMADM"."DBMS_SQL";

CREATE MODULE "SYSIBMADM"."DBMS_STANDARD";

CREATE MODULE "SYSIBMADM"."DBMS_UTILITY";

CREATE MODULE "SYSIBMADM"."MONREPORT";

CREATE MODULE "SYSIBMADM"."UTL_DIR";

CREATE MODULE "SYSIBMADM"."UTL_ENCODE";

CREATE MODULE "SYSIBMADM"."UTL_FILE";

CREATE MODULE "SYSIBMADM"."UTL_MAIL";

CREATE MODULE "SYSIBMADM"."UTL_SMTP";

CREATE MODULE "SYSIBMADM"."UTL_TCP";

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	TYPE "CHARARR" AS VARCHAR(32672) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	TYPE "DESC_REC" AS ROW(
	COL_TYPE INTEGER, 
	COL_MAX_LEN INTEGER, 
	COL_NAME VARCHAR(128), 
	COL_NAME_LEN INTEGER, 
	COL_SCHEMA_NAME VARCHAR(128), 
	COL_SCHEMA_NAME_LEN INTEGER, 
	COL_PRECISION INTEGER, 
	COL_SCALE INTEGER, 
	COL_CHARSETID INTEGER, 
	COL_CHARSETFORM INTEGER, 
	COL_NULL_OK INTEGER);

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	TYPE "DESC_REC2" AS ROW(
	COL_TYPE INTEGER, 
	COL_MAX_LEN INTEGER, 
	COL_NAME VARCHAR(128), 
	COL_NAME_LEN INTEGER, 
	COL_SCHEMA_NAME VARCHAR(128), 
	COL_SCHEMA_NAME_LEN INTEGER, 
	COL_PRECISION INTEGER, 
	COL_SCALE INTEGER, 
	COL_CHARSETID INTEGER, 
	COL_CHARSETFORM INTEGER, 
	COL_NULL_OK INTEGER);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	TYPE "LNAME_ARRAY" AS VARCHAR(4000) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	TYPE "UNCL_ARRAY" AS VARCHAR(227) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONEXEC_TYPE" AS VARCHAR (32) FOR BIT DATA ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_BIGINT_TYPE" AS BIGINT ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR10_TYPE" AS VARCHAR(10) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR128_TYPE" AS VARCHAR(128) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR12_TYPE" AS VARCHAR(12) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR14_TYPE" AS VARCHAR(14) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR16_TYPE" AS VARCHAR(16) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR22_TYPE" AS VARCHAR(22) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR255_TYPE" AS VARCHAR(255) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR256_TYPE" AS VARCHAR(256) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR30_TYPE" AS VARCHAR(30) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR32_TYPE" AS VARCHAR(32) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR3_TYPE" AS VARCHAR(3) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR80_TYPE" AS VARCHAR(80) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CHAR_TYPE" AS VARCHAR(1) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_CLOB_TYPE" AS CLOB(2097152) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_INT_TYPE" AS INTEGER ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_SMALLINT_TYPE" AS SMALLINT ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "MONMETRICS_TIMESTAMP_TYPE" AS TIMESTAMP ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	TYPE "REPORT_TYPE" AS VARCHAR(80) ARRAY [2147483647];

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH TYPE "FILE_TYPE" AS INTEGER WITH COMPARISONS;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	TYPE "CONNECTION" AS ROW(
	HOST VARCHAR(255), 
	PORT INTEGER, 
	TX_TIMEOUT INTEGER, 
	PRIVATE_SD INTEGER, 
	PRIVATE_NEWLINE VARCHAR(2), 
	PRIVATE_STATE INTEGER);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	TYPE "REPLY" AS ROW(
	CODE INTEGER, 
	TEXT VARCHAR(508));

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	TYPE "CONNECTION" AS ROW(
	REMOTE_HOST VARCHAR(255), 
	REMOTE_PORT INTEGER, 
	NEWLINE VARCHAR(2), 
	TX_TIMEOUT INTEGER, 
	PRIVATE_SD INTEGER);

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	VARIABLE "MAXWAIT" INTEGER
	CONSTANT (86400000);

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	VARIABLE "MAX_FAILURE_COUNT" SMALLINT
	CONSTANT (16);

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	VARIABLE "ANY_INSTANCE" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	VARIABLE "TASK_NAME_PREFIX" VARCHAR(14)
	CONSTANT ('DBMS_JOB_TASK_');

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	VARIABLE "MAXBUFSIZE" INTEGER
	CONSTANT (32672);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	VARIABLE "NOVALUE" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	VARIABLE "RETURNSTATUS" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	VARIABLE "THROWERROR" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	VARIABLE "VALID" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "CALL" INTEGER
	CONSTANT (12);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "COMPRESS_OFF" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "COMPRESS_ON" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "DEDUPLICATE_OFF" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "DEDUPLICATE_ON" INTEGER
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "DEFAULT_CSID" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "DEFAULT_LANG_CTX" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "ENCRYPT_OFF" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "ENCRYPT_ON" INTEGER
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "FILE_READONLY" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "LOBMAXSIZE" INTEGER
	CONSTANT (2147483647);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "LOB_READONLY" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "LOB_READWRITE" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "NO_WARNING" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "OPT_COMPRESS" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "OPT_DEDUPLICATE" INTEGER
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "OPT_ENCRYPT" INTEGER
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "SESSION" INTEGER
	CONSTANT (10);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "TRANSACTION" INTEGER
	CONSTANT (11);

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	VARIABLE "WARN_INCONVERTIBLE_CHAR" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	VARIABLE "MAXWAIT" INTEGER
	CONSTANT (86400000);

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	VARIABLE "NATIVE" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_AT" SMALLINT
	CONSTANT (5);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_COMMA" SMALLINT
	CONSTANT (6);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_DOT" SMALLINT
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_EMPTY" SMALLINT
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_END" SMALLINT
	CONSTANT (3);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_INVALID" SMALLINT
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "DELIMITER_TYPE_SPACE" SMALLINT
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "MAX_IDENTIFIER_LENGTH" SMALLINT
	CONSTANT (128);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "OPTION_DISABLED" CHAR(1)
	CONSTANT ('D');

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "OPTION_ENABLED" CHAR(1)
	CONSTANT ('E');

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "OPTION_SET" CHAR(1)
	CONSTANT ('S');

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_INT_START" SMALLINT
	CONSTANT (6);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_QUOTE_END" SMALLINT
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_QUOTE_START" SMALLINT
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_SPACE_AT_END" SMALLINT
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_START" SMALLINT
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_STRING_START" SMALLINT
	CONSTANT (3);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "STATE_UNDERSCORE" SMALLINT
	CONSTANT (5);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INTEGER" SMALLINT
	CONSTANT (7);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INVALID" SMALLINT
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INVALID_CHARACTER" SMALLINT
	CONSTANT (3);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INVALID_IDENTIFIER_TOO_LONG" SMALLINT
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INVALID_MISSING_DOUBLE_QUOTE" SMALLINT
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_INVALID_MISSING_PERIOD" SMALLINT
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_QUOTED" SMALLINT
	CONSTANT (5);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	VARIABLE "TOKEN_TYPE_STRING" SMALLINT
	CONSTANT (6);

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	VARIABLE "INV_ERROR_ON_RESTRICTIONS" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "DEFAULT_PORT" INTEGER
	CONSTANT (25);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "FOLDMESSAGEBODY" BOOLEAN
	DEFAULT (FALSE);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "LOCALHOSTNAME" VARCHAR(255)
	DEFAULT ('localhost');

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_QUOTE_END" SMALLINT
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_QUOTE_START" SMALLINT
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_SPACE_AT_END" SMALLINT
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_START" SMALLINT
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_STRING_START" SMALLINT
	CONSTANT (3);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "STATE_UNDERSCORE" SMALLINT
	CONSTANT (5);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	VARIABLE "TIMEOUT" INTEGER
	CONSTANT (10);

ALTER MODULE "SYSIBMADM"."UTL_MAIL" PUBLISH
	VARIABLE "SMTP_SERVER" VARCHAR(255);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_CONNECTED" INTEGER
	CONSTANT (1);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_HELO_SENT" INTEGER
	CONSTANT (2);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_INITIAL" INTEGER
	CONSTANT (0);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_MAIL_FROM_SENT" INTEGER
	CONSTANT (3);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_OPEN_DATA_SENT" INTEGER
	CONSTANT (5);

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	VARIABLE "STATE_RCPT_TO_SENT" INTEGER
	CONSTANT (4);

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	VARIABLE "CRLF" VARCHAR(2)
	CONSTANT (CHR(13) || CHR (10));

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "ACCESS_ERROR" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "INVALID_ARGVAL" FOR SQLSTATE '5UA0J';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "INVALID_DIRECTORY" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "NOEXIST_DIRECTORY" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "NOPRIV_DIRECTORY" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "OPEN_TOOMANY" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "OPERATION_FAILED" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	CONDITION "UNOPENED_FILE" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "ACCESS_DENIED" FOR SQLSTATE '5UA0K';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "CHARSETMISMATCH" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "DELETE_FAILED" FOR SQLSTATE '5UA0C';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "FILE_OPEN" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INTERNAL_ERROR" FOR SQLSTATE '5UA0L';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_FILEHANDLE" FOR SQLSTATE '5UA07';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_FILENAME" FOR SQLSTATE '5UA05';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_MAXLINESIZE" FOR SQLSTATE '5UA09';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_MODE" FOR SQLSTATE '5UA08';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_OFFSET" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_OPERATION" FOR SQLSTATE '58024';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "INVALID_PATH" FOR SQLSTATE '5UA06';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "READ_ERROR" FOR SQLSTATE '5UA0A';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "RENAME_FAILED" FOR SQLSTATE '5UA0D';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	CONDITION "WRITE_ERROR" FOR SQLSTATE '5UA0B';

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	CONDITION "INVALID_OPERATION" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	CONDITION "PERMANENT_ERROR" FOR SQLSTATE '5UA0F';

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	CONDITION "TRANSIENT_ERROR" FOR SQLSTATE '5UA0E';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "BAD_ARGUMENT" FOR SQLSTATE '5UA0I';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "BUFFER_TOO_SMALL" FOR SQLSTATE '54035';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "END_OF_INPUT" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "NETWORK_ERROR" FOR SQLSTATE '5UA0H';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "PARTIAL_MULTIBYTE_CHAR" FOR SQLSTATE 'ULL  ';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	CONDITION "TRANSFER_TIMEOUT" FOR SQLSTATE '5UA0G';

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  "SLEEP2"(APPLICATIONID VARCHAR(128))
	SPECIFIC DBMS_ALERT_SLEEP2
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_alert_sleep2';

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  CHECK_ALERT_NAME(name VARCHAR(128), routineName VARCHAR(128) )       SPECIFIC DBMS_ALERT_CHECK_ALERT_NAME       BEGIN         IF name IS NULL THEN           /* SIGNAL SQLSTATE '42610' SET MESSAGE_TEXT = 'NULL alert name not allowed'; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', routineName, 'NAME' );         ELSEIF length(name) = 0 THEN           /* SIGNAL SQLSTATE '42617' SET MESSAGE_TEXT = 'Empty alert name not allowed'; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', routineName, 'NAME' );         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  CLEANUP()       SPECIFIC DBMS_ALERT_CLEANUP       BEGIN         DECLARE stmt VARCHAR(200);         DECLARE SQLCODE1 INTEGER;         DECLARE SQLCODE  INTEGER;                 /* Ignore any error */         DECLARE CONTINUE HANDLER FOR SQLEXCEPTION           SET SQLCODE1 = SQLCODE;                 /* If we can't obtain the lock needed for the DELETE, */         /* just skip the operation, let someone else do the cleanup later */         SET LOCK TIMEOUT 5;                 /* Remove terminated applications from DBMS_ALERT_INFO  */         SET stmt = 'DELETE FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid NOT IN (SELECT appl_id FROM SYSIBMADM.APPLICATIONS)';         EXECUTE IMMEDIATE stmt;         COMMIT;                 SET LOCK TIMEOUT NULL;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  INIT()      SPECIFIC DBMS_ALERT_INIT      AUTONOMOUS       BEGIN         /* Creates the SYSTOOLS.DBMS_ALERT_INFO table in SYSTOOLSPACE */         CALL SYSINSTALLOBJECTS( 'DBMS_ALERT', 'C', NULL, NULL );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  MY_SYS_INIT()      SPECIFIC DBMS_ALERT_MY_SYS_INIT       BEGIN         DECLARE stmt VARCHAR(200);         DECLARE found INTEGER;         DECLARE SQLCODE1 INTEGER;         DECLARE SQLCODE  INTEGER;                 /* Ignore error related to object that already exists */         DECLARE CONTINUE HANDLER FOR SQLSTATE '42710'           SET SQLCODE1 = SQLCODE;                 SELECT COUNT(*) INTO found FROM SYSCAT.TABLES           WHERE TABSCHEMA = 'SYSTOOLS' AND TABNAME = 'DBMS_ALERT_INFO';                 IF found = 0 THEN           CALL DBMS_ALERT.INIT();         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  REGISTER_INTERNAL( name VARCHAR(128), applicationId VARCHAR(128) )       SPECIFIC DBMS_ALERT_REGISTER_INTERNAL       AUTONOMOUS       BEGIN        DECLARE stmt VARCHAR(200);                /* Clean up old registrations */         CALL DBMS_ALERT.CLEANUP();         CALL DBMS_ALERT.CHECK_ALERT_NAME( name, 'DBMS_ALERT.REGISTER' );        SET stmt = 'INSERT INTO SYSTOOLS.DBMS_ALERT_INFO VALUES(:name, :applicationId, ''N'', NULL)';        PREPARE S1 FROM stmt;        EXECUTE S1 USING name, applicationId;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  REMOVEALL_INTERNAL( applicationId VARCHAR(128) )       SPECIFIC DBMS_ALERT_REMOVEALL_INTERNAL       AUTONOMOUS       BEGIN        DECLARE stmt VARCHAR(200);        SET stmt = 'DELETE FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid = :applicationId';        PREPARE S1 FROM stmt;        EXECUTE S1 USING applicationId;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  REMOVE_INTERNAL( name VARCHAR(128), applicationId VARCHAR(128) )       SPECIFIC DBMS_ALERT_REMOVE_INTERNAL       AUTONOMOUS       BEGIN        DECLARE stmt VARCHAR(200);         DECLARE SQLCODE INTEGER;         DECLARE SQLCODE1 INTEGER;         /* If the name is not found, just continue */         DECLARE CONTINUE HANDLER FOR NOT FOUND           SET SQLCODE1 = SQLCODE;                 CALL DBMS_ALERT.CHECK_ALERT_NAME( name, 'DBMS_ALERT.REMOVE' );        SET stmt = 'DELETE FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid = :applicationId AND name = :name';        PREPARE S1 FROM stmt;        EXECUTE S1 USING applicationId, name;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  SIGNAL_INTERNAL( name VARCHAR(128), message VARCHAR(1800) )       SPECIFIC DBMS_ALERT_SIGNAL_INTERNAL       BEGIN        DECLARE stmt VARCHAR(200);        DECLARE SQLCODE INTEGER;        /* It is ok to have no rows updated, meaning no alert of */        /* the given name is registered                          */        DECLARE continue HANDLER FOR SQLSTATE '02000' BEGIN END;                CALL DBMS_ALERT.CHECK_ALERT_NAME( name, 'DBMS_ALERT.SIGNAL' );        SET stmt =          'UPDATE SYSTOOLS.DBMS_ALERT_INFO SET (message, changed) = (:message, ''Y'') WHERE name = :name';        PREPARE S1 FROM stmt;        EXECUTE S1 USING message, name;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  WAITANY_INTERNAL( OUT name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER, IN timeout INTEGER, IN applicationId VARCHAR(128) )       SPECIFIC DBMS_ALERT_WAITANY_INTERNAL       AUTONOMOUS       BEGIN        DECLARE stmt VARCHAR(200);        DECLARE stmt2 VARCHAR(200);         DECLARE SQLCODE INTEGER;         DECLARE endTime TIMESTAMP;          DECLARE vchanged VARCHAR(1);         DECLARE alertCount INTEGER;         DECLARE C1 CURSOR FOR S1;        DECLARE C2 CURSOR FOR S2;               SET stmt2 = 'SELECT COUNT(name) FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid = :applicationId FOR READ ONLY';        PREPARE S2 FROM stmt2;        OPEN C2 USING applicationId;        FETCH C2 INTO alertCount;        CLOSE C2;                  /* The behaviour for no alerts registered is different between     */         /* WAITONE and WAITANY. WAITONE will wait for timeout, but WAITANY */         /* will return an error indicating that no alerts are registered.  */                 IF 0 = alertCount THEN           /* SIGNAL SQLSTATE '99999' SET MESSAGE_TEXT = 'no alerts registered'; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20512, NULL );         END IF;                 SET endTime = CURRENT TIMESTAMP + timeout SECONDS;        SET status = 1;               SET stmt = 'SELECT name, message, changed FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid = :applicationId AND changed = ''Y'' FOR READ ONLY';        PREPARE S1 FROM stmt;               loop: LOOP          OPEN C1 USING applicationId;           FETCH C1 INTO name, message, vchanged;           CLOSE C1;                      IF name IS NOT NULL AND length(name) != 0 AND vchanged = 'Y' THEN             LEAVE loop;           END IF;                      /* Is timeout reached? */           IF CURRENT TIMESTAMP > endTime THEN             LEAVE loop;           END IF;                      /* Sleep */           CALL DBMS_ALERT.SLEEP2( applicationId );         END LOOP;                  IF name IS NOT NULL AND length(name) != 0 AND vchanged = 'Y' THEN           SET status = 0;                     SET stmt = 'UPDATE SYSTOOLS.DBMS_ALERT_INFO SET changed = ''N'' WHERE sid = :applicationId AND name = :name';          PREPARE S1 FROM stmt;          EXECUTE S1 USING applicationId, name;         END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" ADD
	PROCEDURE  WAITONE_INTERNAL( IN name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER, IN timeout INTEGER, IN applicationId VARCHAR(128) )       SPECIFIC DBMS_ALERT_WAITONE_INTERNAL       AUTONOMOUS       BEGIN        DECLARE stmt VARCHAR(200);         DECLARE SQLCODE INTEGER;         DECLARE endTime TIMESTAMP;          DECLARE vchanged VARCHAR(1);         DECLARE C1 CURSOR FOR S1;                 CALL DBMS_ALERT.CHECK_ALERT_NAME( name, 'DBMS_ALERT.WAITONE' );         SET endTime = CURRENT TIMESTAMP + timeout SECONDS;         SET status = 1;         loop: LOOP          SET stmt = 'SELECT message, changed FROM SYSTOOLS.DBMS_ALERT_INFO WHERE sid = :applicationId AND name = :name AND changed = ''Y'' FOR READ ONLY';          PREPARE S1 FROM stmt;          OPEN C1 USING applicationId, name;          FETCH C1 INTO message, vchanged;          CLOSE C1;                      /* Keep looping until time expires or we find a new message */           IF vchanged = 'Y' THEN             LEAVE loop;           END IF;                      /* Is timeout reached? */           IF CURRENT TIMESTAMP > endTime THEN             LEAVE loop;           END IF;                      /* Sleep */           CALL DBMS_ALERT.SLEEP2( applicationId );         END LOOP;                  IF vchanged = 'Y' THEN           SET status = 0;                     SET stmt = 'UPDATE SYSTOOLS.DBMS_ALERT_INFO SET changed = ''N'' WHERE sid = :applicationId AND name = :name';          PREPARE S1 FROM stmt;          EXECUTE S1 USING applicationId, name;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  "SET_DEFAULTS"(SENSITIVITY INTEGER)
	SPECIFIC DBMS_ALERT_SET_DEFAULTS
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_alert_set_defaults';

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  "SLEEP"(TIMEOUT INTEGER)
	SPECIFIC DBMS_ALERT_SLEEP
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_alert_sleep';

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  REGISTER( name VARCHAR(128) )       SPECIFIC DBMS_ALERT_REGISTER       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 /* We need to call APPLICATION_ID() here since an autonomous  */         /* procedure has a different application ID                   */         CALL DBMS_ALERT.REGISTER_INTERNAL( name, APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  REMOVE( name VARCHAR(128) )       SPECIFIC DBMS_ALERT_REMOVE       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.REMOVE_INTERNAL( name, APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  REMOVEALL()       SPECIFIC DBMS_ALERT_REMOVEALL       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.REMOVEALL_INTERNAL( APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  SIGNAL( name VARCHAR(128), message VARCHAR(1800) )       SPECIFIC DBMS_ALERT_SIGNAL       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.SIGNAL_INTERNAL( name, message );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  WAITANY( OUT name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER )       SPECIFIC DBMS_ALERT_WAITANY_2       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.WAITANY_INTERNAL( name, message, status, DBMS_ALERT.MAXWAIT, APPLICATION_ID() );         END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  WAITANY( OUT name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER, IN timeout INTEGER )       SPECIFIC DBMS_ALERT_WAITANY       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.WAITANY_INTERNAL( name, message, status, timeout, APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  WAITONE( IN name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER )       SPECIFIC DBMS_ALERT_WAITONE_2       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.WAITONE_INTERNAL( name, message, status, DBMS_ALERT.MAXWAIT, APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_ALERT" PUBLISH
	PROCEDURE  WAITONE( IN name VARCHAR(128), OUT message VARCHAR(1800), OUT status INTEGER, IN timeout INTEGER )       SPECIFIC DBMS_ALERT_WAITONE       BEGIN        CALL DBMS_ALERT.MY_SYS_INIT();                 CALL DBMS_ALERT.WAITONE_INTERNAL( name, message, status, timeout, APPLICATION_ID() );       END;

ALTER MODULE "SYSIBMADM"."DBMS_DDL" PUBLISH
	FUNCTION  "WRAP"(DDL CLOB(2097152))
	RETURNS CLOB(2097152)
	LANGUAGE C
	SPECIFIC DBMS_DDL_WRAP
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_DDL" PUBLISH
	PROCEDURE  CREATE_WRAPPED( IN ddl CLOB(2M) )       SPECIFIC DBMS_DDL_CREATE_WRAPPED       BEGIN         EXECUTE IMMEDIATE SYSIBMADM.DBMS_DDL.WRAP(ddl);       END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  GET_NEXTRUN_TIME(interval TIMESTAMP, OUT nextRun TIMESTAMP)       SPECIFIC DBMS_JOB_GET_NEXTRUN_TIME       MODIFIES SQL DATA       LANGUAGE SQL       BEGIN           SET nextRun = interval;       END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  GET_SCHEMA_QUALIFIED(in_value VARCHAR(1024), OUT out_value VARCHAR(2048), isWhat BOOLEAN)       SPECIFIC DBMS_JOB_GET_SCHEMA_QUALIFIED       LANGUAGE SQL         BEGIN           DECLARE isOkay  BOOLEAN DEFAULT true;           DECLARE ddlStmt VARCHAR(2100);                 DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, NOT FOUND, SQLWARNING           BEGIN             SET isOkay = false;           END;                 SET out_value = NULL;                 IF ((in_value IS NOT NULL) AND (LENGTH(in_value) <> 0)) THEN             SET in_value = STRIP(REPLACE(in_value, '''', ''''''), TRAILING, ';');                   /*             ** Check the case if what is present in the CURRENT SCHEMA.             */             SET out_value = CURRENT SCHEMA || '.' || in_value;                   IF (isWhat = true) THEN               SET ddlStmt = 'CALL ' || CURRENT SCHEMA || '.' || in_value;             ELSE               SET ddlStmt = 'CALL DBMS_JOB.GET_NEXTRUN_TIME(' || CURRENT SCHEMA || '.' || in_value || ',?)';             END IF;                   PREPARE preparedStmt FROM ddlStmt;                   IF (isOkay = false) THEN               /*               ** It seems that function/procedure is not present in the CURRENT SCHEMA therefore assume that               ** user has provided us the value correctly i.e.               **               **   a) In case of interval, in_value is NOT a user defined function that returns a date value.               **   b) In case of what procedure either in_value has been specified with a schema already or it has not               **      been defined yet (the case when user submits the job before creating the task's procedure).               */               SET out_value = in_value;             END IF;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  GET_TASK_INFO(taskName VARCHAR(34), OUT what VARCHAR(1024), OUT nextDate TIMESTAMP, OUT interval VARCHAR(1024), OUT maxInvocation SMALLINT)       SPECIFIC DBMS_JOB_GET_TASK_INFO       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE procInput      VARCHAR(2048);           DECLARE stmt VARCHAR(200) DEFAULT              'SELECT max_invocations, begin_time, procedure_input FROM SYSTOOLS.ADMIN_TASK_LIST WHERE name = :taskName';           DECLARE C1 CURSOR FOR S1;                     /*           SELECT             max_invocations, begin_time, procedure_input INTO maxInvocation, nextDate, procInput           FROM             SYSTOOLS.ADMIN_TASK_LIST           WHERE             name = taskName;           */           PREPARE S1 FROM stmt;           OPEN C1 USING taskName;           FETCH C1 INTO maxInvocation, nextDate, procInput;           CLOSE C1;               /* Since there will always be an interval difference between current time and the time */         /* when the task has been submitted to the ATS, we are checking the nextDate value exist in */         /* in the near future enough so that ATS does not reject it because it considers the task's */         /* nextDate value is in the past (with respect to the time it is considering the task to add in its */         /* list of tasks). */         /* Also, since, a newly added/updated tasks gets executed after 5 minutes (max.) by ATS, */         /* we can assume that the following condition won't affects those tasks which next execution time */         /* is within the next 10 seconds (as it will not get executed by ATS since it has been updated). */           IF (nextDate IS NOT NULL) AND (nextDate < SYSDATE + 10 SECONDS) THEN              SET nextDate = NULL;           END IF;               /* Fetch 'user procedure' and 'interval' information which has been saved as part of */         /* procedure_input when the task has been submitted to ATS. */         /* Here: */         /* SUBSTR(procInput, 8, LENGTH(procInput) - 8) = '''taskName'', ''interval'', ''what''' */           SET procInput = TRIM(procInput);           PREPARE preparedStmt FROM 'CALL DBMS_JOB.PARSE_VALUES (' || SUBSTR(procInput, 8, LENGTH(procInput)-8) || ',?,?)';           EXECUTE preparedStmt INTO what, interval;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  GET_TASK_NAME(job DECIMAL(20), OUT taskName VARCHAR(34))       SPECIFIC DBMS_JOB_GET_TASK_NAME       BEGIN         DECLARE numTasks    SMALLINT     DEFAULT 0;         DECLARE stmt        VARCHAR(200) DEFAULT 'SELECT COUNT(*) FROM SYSTOOLS.ADMIN_TASK_LIST WHERE name = :taskName';         DECLARE messageText VARCHAR(200);         DECLARE C1          CURSOR FOR S1;                 IF (job IS NULL) OR (job < 1) THEN           SET taskName = DBMS_JOB.TASK_NAME_PREFIX || 'NULL';         ELSE           SET taskName = DBMS_JOB.TASK_NAME_PREFIX || job;                     PREPARE S1 FROM stmt;           OPEN C1 USING taskName;           FETCH C1 INTO numTasks;           CLOSE C1;         END IF;                 IF (numTasks = 0) THEN           /* SET messageText = 'Job number ' || job || ' is not a job in the job queue.'; */           /* SIGNAL SQLSTATE '23421' SET MESSAGE_TEXT = messageText; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -204, taskName );         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  HANDLE_TASK_NEXT_RUN(taskName VARCHAR(34), nextDate TIMESTAMP, exceptionFlag BOOLEAN)       SPECIFIC DBMS_JOB_HANDLE_TASK_NEXT_RUN       LANGUAGE SQL         BEGIN           DECLARE retryCount      SMALLINT;           DECLARE maxInvocations  SMALLINT;           DECLARE stmt VARCHAR(200) DEFAULT              'SELECT CAST(remarks AS SMALLINT) - 1 FROM SYSTOOLS.ADMIN_TASK_LIST WHERE name = :taskName';           DECLARE C1 CURSOR FOR S1;                     IF (nextDate IS NOT NULL) THEN                   IF ( false = exceptionFlag ) THEN               /*                ** Reset the retryCount to its initial default value since user procedure has               ** completed its execution successfully.               */                SET retryCount = DBMS_JOB.MAX_FAILURE_COUNT;             ELSE               /*               ** Decrement retryCount counter in order to ensure that current task's gets marked broken               ** when its execution fails 16 consecutive times.               */                /*               SELECT                 CAST(remarks AS SMALLINT) - 1 INTO retryCount               FROM                 SYSTOOLS.ADMIN_TASK_LIST                WHERE                 name = taskName;               */                     PREPARE S1 FROM stmt;               OPEN C1 USING taskName;               FETCH C1 INTO retryCount;               CLOSE C1;             END IF;                   /*             ** Set maxInvocations to 0 (so that ATS ignores executing the task later) when retryCount falls below 1,             ** otherwise set maxInvocations to 1 so that the task get executed exactly ONCE on its next run.             */              IF ( retryCount <= 0 ) THEN               SET retryCount = 0;               SET maxInvocations = 0;             ELSE               SET maxInvocations = 1;             END IF;                   /*             ** Since there will always be an interval difference between current time and the time             ** when the task has been submitted to the ATS, we are checking the nextDate value exist in             ** in the near future enough so that ATS does not reject it because it considers the task's             ** nextDate value is in the past (with respect to the time it is considering the task to add in its             ** list of tasks).             **             ** Also, since, a newly added/updated tasks gets executed after 5 minutes (max.) by ATS,             ** we can assume that the following condition won't affects those tasks which next execution time             ** is within the next 10 seconds (as it will not get executed by ATS since it has been updated).             */              IF (nextDate IS NOT NULL) AND (nextDate < SYSDATE + 10 SECONDS) THEN               SET nextDate = NULL;             END IF;                   /*             ** Update the task according to the information gathered above.             */             CALL SYSPROC.ADMIN_TASK_UPDATE(               taskName,       /* name              */               nextDate,       /* nextrun/next_date */               NULL,           /* end-timestamp     */               maxInvocations, /* max-invocations   */               NULL,           /* schedule          */               NULL,           /* options           */               retryCount);    /* remarks           */           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  IMP_CHANGE(job DECIMAL(20), what VARCHAR(1024), next_date TIMESTAMP(0), interval VARCHAR(1024), instance INTEGER, force BOOLEAN, routineName VARCHAR(257))       SPECIFIC DBMS_JOB_IMP_CHANGE       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE taskName          VARCHAR(34);           DECLARE oldTaskProc       VARCHAR(1024);           DECLARE oldNextDate       TIMESTAMP;           DECLARE newNextDate       TIMESTAMP;           DECLARE oldInterval       VARCHAR(1024);           DECLARE oldMaxInvocation  SMALLINT;                 CALL DBMS_JOB.GET_TASK_NAME(job, taskName);                 /*           ** Get rest of the information about this task.           */           CALL DBMS_JOB.GET_TASK_INFO(             taskName,          /* job/task name         */             oldTaskProc,       /* actual user procedure */             oldNextDate,       /* nextrun               */             oldInterval,       /* interval              */             oldMaxInvocation); /* maxInvocation         */                 /*           ** Use old task information for all arguments having a NULL value.           ** Treat empty-string as NULL.           */           IF ((what IS NULL) OR (LENGTH(what) = 0)) THEN             SET what = oldTaskProc;           END IF;                 IF (next_date IS NULL) THEN             SET newNextDate = oldNextDate;           ELSE             SET newNextDate = next_date;           END IF;                 IF ((interval IS NULL) OR (LENGTH(interval) = 0)) THEN             SET interval = oldInterval;           END IF;                 IF (instance IS NOT NULL AND instance <> DBMS_JOB.ANY_INSTANCE) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '5', routineName, 'INSTANCE' );           END IF;                 /*           ** Drop old task from ATS and create a new task with the help of           ** latest information provided.           */           CALL DBMS_JOB.REMOVE(job);                 CALL DBMS_JOB.imp_SUBMIT(             job,               /* job/task name                           */             what,              /* process to be invoked at scheduled time */             newNextDate,       /* nextrun/next_date                       */             interval,          /* interval                                */             false,             /* no_parse                                */             instance,          /* Instance id to run the task             */             force,             /* force                                   */             routineName,       /* routine name                            */             oldMaxInvocation); /* maxInvocation                           */         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  INIT_ATS()       SPECIFIC DBMS_JOB_INIT_ATS       AUTONOMOUS        BEGIN          /* Creates the SYSTOOLS.ADMIN_TASK_LIST table in SYSTOOLSPACE */          CALL SYSINSTALLOBJECTS( 'DBMS_JOB', 'C', NULL, NULL );        END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  IS_VALID(what VARCHAR(1024), noParse BOOLEAN, interval VARCHAR(1024), routineName VARCHAR(257), OUT valid BOOLEAN)       SPECIFIC DBMS_JOB_IS_VALID       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE ddlStmt           VARCHAR(1032);           DECLARE nextDate          TIMESTAMP;                     SET valid = false;                     /* Determine if the interval evaluates into a time in the future. If */           /* not then throw an exception otherwise proceed as normal.           */           IF (interval IS NOT NULL) THEN             SET interval = TRIM(interval);             IF (LENGTH(interval) = 0) THEN               /* SIGNAL SQLSTATE '23420' SET MESSAGE_TEXT = 'Interval must evaluate to a time in the future'; */               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '0', routineName, 'INTERVAL' );             ELSE                     SET ddlStmt = 'CALL DBMS_JOB.GET_NEXTRUN_TIME(' || interval || ',?)';                       PREPARE preparedStmt FROM ddlStmt;               EXECUTE preparedStmt INTO nextDate;                       /*               ** Evaluating 'interval' must always result into a future timestamp value.               */               IF (NOT(nextDate > SYSDATE)) THEN                 /* SIGNAL SQLSTATE '23420' SET MESSAGE_TEXT = 'Interval must evaluate to a time in the future'; */                 CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '0', routineName, 'INTERVAL' );               END IF;             END IF;           END IF;                 /* If user wants to parse the submitted procedure then we just PREPARE the procedure */           /* without calling it. Hence if the procedure does not exist or has any problem */           /* PREPARE command would fail and throw appropriate exception. */           /* Otherwise we will submit the task without checking the current state of the procedure. */           IF (what IS NOT NULL) THEN             IF ((what IS NULL) OR (0 = LENGTH(TRIM(what)))) THEN               /* SIGNAL SQLSTATE '42704' SET MESSAGE_TEXT = 'Invalid procedure name.'; */               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '0', routineName, 'WHAT' );             END IF;           ELSE             /* SIGNAL SQLSTATE '42704' SET MESSAGE_TEXT = 'Invalid procedure name.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '0', routineName, 'WHAT' );           END IF;                 IF ( noParse = false ) THEN               SET ddlStmt = 'BEGIN ' || STRIP(what, TRAILING, ';') || '; END';               PREPARE preparedStmt FROM ddlStmt;           END IF;                     SET valid = true;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  PARSE_VALUES(job VARCHAR(32), intervalIn VARCHAR(1024), whatIn VARCHAR(1024), OUT whatOut VARCHAR(1024), OUT intervalOut VARCHAR(1024))       SPECIFIC DBMS_JOB_PARSE_VALUES       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           IF ( whatIn IS NOT NULL ) THEN             SET whatOut = TRIM(whatIn);           ELSE             SET whatOut = NULL;           END IF;                 IF ( intervalIn IS NOT NULL ) THEN             SET intervalOut = TRIM(intervalIn);           ELSE             SET intervalOut = NULL;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  PREPARE_TASK_INFO(job DECIMAL(20), what VARCHAR(1024), interval VARCHAR(1024), OUT taskName VARCHAR(34), OUT procSchema VARCHAR(1024), OUT procName VARCHAR(1024), OUT procInput VARCHAR(1024))       SPECIFIC DBMS_JOB_PREPARE_TASK_INFO       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE schema_qualified_what     VARCHAR(2048);           DECLARE schema_qualified_interval VARCHAR(2048);                     IF (what IS NOT NULL) AND (0 <> LENGTH(what)) THEN             SET taskName    = DBMS_JOB.TASK_NAME_PREFIX || job;             SET procSchema  = 'DBMS_JOB';             SET procName    = 'EXECUTE_TASK';             SET procInput   = 'VALUES(''' || taskName || ''',''' ;             IF (interval IS NULL) OR (0 = LENGTH(interval)) THEN               SET procInput = procInput || 'NULL'',''';             ELSE               /*               ** Case a) If Interval is a user defined function that returns a date value and               **         interval is not schema qualified yet then: make it a schema qualified interval.               **               ** Case b) If Interval is NOT a user defined function that returns a date value then:               **         schema_qualified_interval is equal to interval.               */               CALL DBMS_JOB.GET_SCHEMA_QUALIFIED(interval, schema_qualified_interval, false);               SET procInput = procInput || schema_qualified_interval || ''',''';             END IF;                         CALL DBMS_JOB.GET_SCHEMA_QUALIFIED(what, schema_qualified_what, true);             SET procInput   = procInput || schema_qualified_what || ''')';           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  SYS_INIT()       SPECIFIC DBMS_JOB_SYS_INIT        BEGIN          DECLARE stmt VARCHAR(200);          DECLARE found INTEGER;          DECLARE SQLCODE1 INTEGER;          DECLARE SQLCODE  INTEGER;                   /* Ignore error related to object that already exists */          DECLARE CONTINUE HANDLER FOR SQLSTATE '42710'            SET SQLCODE1 = SQLCODE;                   SELECT COUNT(*) INTO found FROM SYSCAT.TABLES            WHERE TABSCHEMA = 'SYSTOOLS' AND TABNAME = 'ADMIN_TASK_LIST';                   IF found = 0 THEN            CALL DBMS_JOB.INIT_ATS();          END IF;        END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" ADD
	PROCEDURE  imp_SUBMIT(job DECIMAL(20), what VARCHAR(1024), nextDate TIMESTAMP, interval VARCHAR(1024), noParse BOOLEAN, instance INTEGER, force BOOLEAN, routineName VARCHAR(257), maxInvocations SMALLINT DEFAULT 1)       SPECIFIC DBMS_JOB_imp_SUBMIT       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE taskName       VARCHAR(34);           DECLARE procSchema     VARCHAR(16);           DECLARE procName       VARCHAR(45);           DECLARE procInput      VARCHAR(1024);           DECLARE outStatus      BOOLEAN;                     CALL DBMS_JOB.IS_VALID( what, noParse , interval, routineName, outStatus );                 IF ( true = outStatus ) THEN                   SET what = TRIM(what);                   IF ( interval IS NOT NULL ) THEN               SET interval = TRIM(interval);             END IF;                   /* Get task related information. And schedule a new task with our wrapper procedure; pass */             /* the 'user procedure' and its related information as input to it so that it can execute */             /* the procedure on its scheduled time. */             CALL DBMS_JOB.PREPARE_TASK_INFO(               job,        /* job/task name            */               what,       /* user task/procedure      */               interval,   /* interval                 */               taskName,   /* task name                */               procSchema, /* wrapper procedure schema */               procName,   /* wrapper procedure name   */               procInput); /* wrapper procedure input  */                 /* Since there will always be an interval difference between current time and the time */           /* when the task has been submitted to the ATS, we are checking the nextDate value exist in */           /* in the near future enough so that ATS does not reject it because it considers the task's */           /* nextDate value is in the past (with respect to the time it is considering the task to add in its */           /* list of tasks). */           /* Also, since, a newly added/updated tasks gets executed after 5 minutes (max.) by ATS, */           /* we can assume that the following condition won't affects those tasks which next execution time */           /* is within the next 10 seconds (as it will not get executed by ATS since it has been updated). */             IF (nextDate IS NOT NULL) AND (nextDate < SYSDATE + 10 SECONDS) THEN               SET nextDate = NULL;             END IF;                   CALL SYSPROC.ADMIN_TASK_ADD(               taskName,                     /* job/task name    */               nextDate,                     /* begin-timestamp  */               NULL,                         /* end-timestamp    */               maxInvocations,               /* max-invocations  */               NULL,                         /* schedule         */               procSchema,                   /* procedure-schema */               procName,                     /* procedure-name   */               procInput,                    /* procedure-input  */               NULL,                         /* options          */               DBMS_JOB.MAX_FAILURE_COUNT);  /* remarks          */           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  BROKEN(job DECIMAL(20), broken BOOLEAN, next_date TIMESTAMP(0) DEFAULT SYSDATE)       SPECIFIC DBMS_JOB_BROKEN       LANGUAGE SQL         BEGIN           DECLARE maxInvocation   SMALLINT;           DECLARE taskName        VARCHAR(34);           DECLARE retryCount      SMALLINT;                 CALL DBMS_JOB.GET_TASK_NAME(job, taskName);                 /*           ** Set task's max-invocations to 0 if it is broken, otherwise, set it           ** to value of 1 we want this to be executed exactly one time. And update           ** the task in ATS accordingly.           */           IF (broken = true) THEN             SET retryCount    = 0;             SET maxInvocation = 0;           ELSE             SET retryCount    = DBMS_JOB.MAX_FAILURE_COUNT;             SET maxInvocation = 1;           END IF;                 /*           ** When next_date parameter's value is NULL, Execute the task only once and stop executing           ** it anymore.           */           IF ((broken = false) AND (next_date IS NULL)) THEN             CALL DBMS_JOB.RUN(job);             SET maxInvocation = 0;           ELSEIF ((next_date IS NOT NULL) AND (next_date < SYSDATE + 10 SECONDS)) THEN             /*             ** Since there will always be an interval difference between current time and the time             ** when the task is being updated, here, we are checking the next_date value exist in             ** in the near future enough so that ATS does not reject it because it considers the task's             ** nextDate value is in the past (with respect to the time it is considering the task to add in its             ** list of tasks).             **             ** Also, since, a newly added/updated tasks gets executed after 5 minutes (max.) by ATS,             ** we can assume that the following condition won't affects those tasks which next execution time             ** is within the next 10 seconds (as it will not get executed by ATS since it has been updated).             */             SET next_date = NULL;           END IF;                 CALL SYSPROC.ADMIN_TASK_UPDATE(             taskName,      /* name              */             next_date,     /* nextrun/next_date */             NULL,          /* end-timestamp     */             maxInvocation, /* max-invocations   */             NULL,          /* schedule          */             NULL,          /* options           */             retryCount);   /* remarks           */         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  CHANGE(job DECIMAL(20), what VARCHAR(1024), next_date TIMESTAMP(0), interval VARCHAR(1024), instance INTEGER DEFAULT 0, force BOOLEAN DEFAULT FALSE)       SPECIFIC DBMS_JOB_CHANGE       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           CALL DBMS_JOB.IMP_CHANGE(             job,        /* job                         */             what,       /* actual user procedure (new) */             next_date,  /* next_date                   */             interval,   /* interval                    */             instance,   /* instance                    */             force,      /* force                       */             'DBMS_JOB.CHANGE' ); /* routine name       */         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  EXECUTE_TASK(taskName VARCHAR(34), interval VARCHAR(1024), proc VARCHAR(512))       SPECIFIC DBMS_JOB_EXECUTE_TASK       LANGUAGE SQL         BEGIN           DECLARE ddlStmt       VARCHAR(1024);           DECLARE nextDate      TIMESTAMP;               /* Prepare exception handler for user procedure when it throws an exception */         /* (due to any reason) when it is called/executed. */           DECLARE EXIT HANDLER FOR SQLEXCEPTION, NOT FOUND, SQLWARNING           BEGIN           /* Update current task's retryCount. Here we are calling DBMS_JOB.HANDLE_TASK_NEXT_RUN */           /* with exceptionCase set to TRUE i.e. letting it know that user procedure's execution has */           /* thrown an exception. */             CALL DBMS_JOB.HANDLE_TASK_NEXT_RUN(taskName, nextDate, true);           END;               /* Firstly, determine nextDate value; using this value, we will update task's nextrun time */         /* later (in DBMS_JOB.HANDLE_TASK_NEXT_RUN). */           IF ( interval <> 'NULL' ) THEN             SET ddlStmt = 'CALL DBMS_JOB.GET_NEXTRUN_TIME(' || interval || ',?)';                   PREPARE preparedStmt FROM ddlStmt;             EXECUTE preparedStmt INTO nextDate;           END IF;               /* Call user procedure; It might throw an exception but we don't have to worry about */         /* it since we have our exception-handler ready to handle the case. */           SET ddlStmt = 'BEGIN ' || proc || '; END';           EXECUTE IMMEDIATE ddlStmt;               /* Update current task's nextrun time. Here we are calling DBMS_JOB.HANDLE_TASK_NEXT_RUN */         /* with exceptionCase set to FALSE i.e. letting it know that user procedure's execution has */         /* completed successfully (or without any exception). */           CALL DBMS_JOB.HANDLE_TASK_NEXT_RUN(taskName, nextDate, false);         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  INTERVAL(job DECIMAL(20), interval VARCHAR(1024))       SPECIFIC DBMS_JOB_INTERVAL       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE taskName VARCHAR(34);                 IF ((interval IS NULL) OR (LENGTH(interval)) = 0) THEN             CALL DBMS_JOB.GET_TASK_NAME(job, taskName);                   /*             ** We need to run the job only once, and then make interval in-effective             ** by setting the max-invocations to zero.             */             CALL DBMS_JOB.RUN(job);                   CALL SYSPROC.ADMIN_TASK_UPDATE(               taskName,    /* name            */               NULL,        /* start-timestamp */               NULL,        /* end-timestamp   */               0,           /* max-invocations */               NULL,        /* schedule        */               NULL,        /* options         */               0);          /* remarks         */           ELSE             /*             ** Since for changing the interval, we need to recreate the job so that its starts             ** using new interval, we do it with the help of DBMS_JOB.IMP_CHANGE procedure.             */             CALL DBMS_JOB.IMP_CHANGE(               job,        /* job                   */               NULL,       /* actual user procedure */               NULL,       /* next_date             */               interval,   /* interval (new)        */               0,          /* instance              */               FALSE,      /* force                 */               'DBMS_JOB.INTERVAL' ); /* routine name */           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  NEXT_DATE(job DECIMAL(20), next_date TIMESTAMP(0))       SPECIFIC DBMS_JOB_NEXT_DATE       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE taskName   VARCHAR(34);           DECLARE retryCount VARCHAR(8);           DECLARE stmt       VARCHAR(200) DEFAULT 'SELECT remarks FROM SYSTOOLS.ADMIN_TASK_LIST WHERE name = :taskName';           DECLARE C1         CURSOR FOR S1;                 CALL DBMS_JOB.GET_TASK_NAME(job, taskName);                 /*           ** Update task's start-timestamp with newly next_date value provided BUT           ** keep retryCount unchanged.           **           ** SELECT remarks INTO retryCount FROM SYSTOOLS.ADMIN_TASK_LIST WHERE name = taskName;           */           PREPARE S1 FROM stmt;           OPEN C1 USING taskName;           FETCH C1 INTO retryCount;           CLOSE C1;                 /*           ** When next_date parameter's value is NULL, run it only once and set the next execution time           ** for the job January 1, 4000.           **           ** Oracle built-in packages (O'REILLY, ISBN: 1-56592-375-8)           */           IF (next_date IS NULL) THEN             CALL DBMS_JOB.RUN(job);             SET next_date = CAST('1/1/4000' AS TIMESTAMP(0));           END IF;                 /*           ** Since there will always be an interval difference between current time and the time           ** when the task is being updated, here, we are checking the next_date value exist in           ** in the near future enough so that ATS does not reject it because it considers the task's           ** nextDate value is in the past (with respect to the time it is considering the task to add in its           ** list of tasks).           **           ** Also, since, a newly added/updated tasks gets executed after 5 minutes (max.) by ATS,           ** we can assume that the following condition won't affects those tasks which next execution time           ** is within the next 10 seconds (as it will not get executed by ATS since it has been updated).           */           IF (next_date < SYSDATE + 10 SECONDS) THEN             SET next_date = NULL;           END IF;                 CALL SYSPROC.ADMIN_TASK_UPDATE(             taskName,    /* name            */             next_date,   /* start-timestamp */             NULL,        /* end-timestamp   */             1,           /* max-invocations */             NULL,        /* schedule        */             NULL,        /* options         */             retryCount); /* remarks         */         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  REMOVE(job DECIMAL(20))       SPECIFIC DBMS_JOB_REMOVE       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE taskName VARCHAR(34);                     /*           ** Remove the task from ATS tasks list (besides all associated status records)           ** if it exist.           */           CALL DBMS_JOB.GET_TASK_NAME(job, taskName);           CALL SYSPROC.ADMIN_TASK_REMOVE(taskName, NULL);         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  RUN(job DECIMAL(20), force BOOLEAN DEFAULT FALSE)       SPECIFIC DBMS_JOB_RUN       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           DECLARE ddlStmt           VARCHAR(1032);           DECLARE taskName          VARCHAR(34);           DECLARE taskProc          VARCHAR(1024);           DECLARE nextDate          TIMESTAMP;           DECLARE interval          VARCHAR(1024);           DECLARE maxInvocation     SMALLINT;                 CALL DBMS_JOB.GET_TASK_NAME(job, taskName);                 /*           ** Get rest of the information about this task.           */           CALL DBMS_JOB.GET_TASK_INFO(             taskName,       /* job/task name         */             taskProc,       /* actual user procedure */             nextDate,       /* nextrun               */             interval,       /* interval              */             maxInvocation); /* max-invocations       */                 /*           ** Determine nextRun time of this task using the interval value. And update the           ** task nextRun time accordingly.           */           IF (interval IS NOT NULL) THEN             PREPARE preparedStmt FROM 'CALL DBMS_JOB.GET_NEXTRUN_TIME(' || interval || ',?)';             EXECUTE preparedStmt INTO nextDate;                   CALL SYSPROC.ADMIN_TASK_UPDATE(               taskName,                    /* name            */               nextDate,                    /* nextrun time    */               NULL,                        /* end-timestamp   */               1,                           /* max-invocations */               NULL,                        /* schedule        */               NULL,                        /* options         */               DBMS_JOB.MAX_FAILURE_COUNT); /* remarks         */           END IF;                 SET ddlStmt = 'BEGIN ' || taskProc || '; END';           EXECUTE IMMEDIATE ddlStmt;         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  SUBMIT(OUT job DECIMAL(20), what VARCHAR(1024), next_date TIMESTAMP(0) DEFAULT SYSDATE, interval VARCHAR(1024) DEFAULT NULL, no_parse BOOLEAN DEFAULT FALSE, instance INTEGER DEFAULT 0, force BOOLEAN DEFAULT FALSE)       SPECIFIC DBMS_JOB_SUBMIT       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           /* Get next value from sequence (this new value would serve as this job's Id) */           SET job = NEXTVAL FOR SYSIBM.JOBSEQ;                     /* Treat empty-string as NULL. */           IF ((what IS NOT NULL) AND (LENGTH(what) = 0)) THEN             SET what = NULL;           END IF;                     IF ((interval IS NOT NULL) AND (LENGTH(interval) = 0)) THEN             SET interval = NULL;           END IF;                     CALL DBMS_JOB.imp_SUBMIT(             job,        /* job                                       */             what,       /* procedure to be invoked at scheduled time */             next_date,  /* nextrun/next_date                         */             interval,   /* interval                                  */             no_parse,   /* no_parse/nocheck                          */             instance,   /* Instance id to run the task               */             force,      /* force                                     */             'DBMS_JOB.SUBMIT'); /* routine name                      */         END;

ALTER MODULE "SYSIBMADM"."DBMS_JOB" PUBLISH
	PROCEDURE  WHAT(job DECIMAL(20), what VARCHAR(1024))       SPECIFIC DBMS_JOB_WHAT       MODIFIES SQL DATA       LANGUAGE SQL         BEGIN           IF ((what IS NULL) OR (LENGTH(TRIM(what))) = 0) THEN             /* SIGNAL SQLSTATE '42704' SET MESSAGE_TEXT = 'Invalid procedure name.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_JOB.WHAT', 'WHAT' );           END IF;                 CALL DBMS_JOB.IMP_CHANGE(             job,   /* job                         */             what,  /* actual user procedure (new) */             NULL,  /* next_date                   */             NULL,  /* interval                    */             0,     /* instance                    */             FALSE, /* force                       */             'DBMS_JOB.WHAT' ); /* what            */         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  BUILD_ERROR_MESSAGE(argNum INTEGER) RETURNS VARCHAR(100)       SPECIFIC DBMS_LOB_BUILD_ERROR_MESSAGE       LANGUAGE SQL         BEGIN           RETURN 'argument ' CONCAT                  CAST(argNum AS VARCHAR(10)) CONCAT                  ' is null, invalid, or out of range';         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  BYTESLEFT(len INTEGER, amount INTEGER, offset INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_BYTESLEFT       LANGUAGE SQL         BEGIN           DECLARE amountLeft INTEGER;                 IF offset > len THEN             RETURN 0;           END IF;                 SET amountLeft = len - offset + 1;                 IF amountLeft >= amount THEN             RETURN amount;           ELSE             RETURN amountLeft;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  READ(lob BLOB(10M), amount INTEGER, offset INTEGER) RETURNS  VARCHAR(32672) FOR BIT DATA       SPECIFIC DBMS_LOB_READ_2       LANGUAGE SQL         BEGIN           DECLARE len       INTEGER;           DECLARE bytesLeft INTEGER;                 SET len = LENGTH(lob);                 IF offset > len THEN             /* SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'no data found.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -138, NULL );            ELSE                       SET bytesLeft = DBMS_LOB.BYTESLEFT(len, amount, offset);                       RETURN CAST( SYSIBM.SUBSTR(lob, offset, bytesLeft) AS VARCHAR(32672) FOR BIT DATA );           END IF;        END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  READ(lob CLOB(10M), amount INTEGER, offset INTEGER) RETURNS  VARCHAR(32672)      SPECIFIC DBMS_LOB_READ       LANGUAGE SQL         BEGIN           DECLARE len       INTEGER;           DECLARE bytesLeft INTEGER;                 SET len = LENGTH(lob);                 IF offset > len THEN             /* SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'no data found.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -138, NULL );           ELSE                       SET bytesLeft = DBMS_LOB.BYTESLEFT(len, amount, offset);                       RETURN SYSIBM.SUBSTR(lob, offset, bytesLeft);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  WRITE_TO_LOB(dstLob BLOB(10M), srcLob BLOB(10M), amount INTEGER, dstOffset INTEGER, srcOffset INTEGER) RETURNS BLOB(10M)       SPECIFIC DBMS_LOB_WRITE_TO_LOB_2       LANGUAGE SQL         BEGIN           DECLARE srcLength     INTEGER;           DECLARE dstLength    INTEGER;           DECLARE bytesToCopy   INTEGER;                 SET srcLength = LENGTH(srcLob);           SET dstLength = LENGTH(dstLob);           SET bytesToCopy = DBMS_LOB.BYTESLEFT(srcLength, amount, srcOffset);         /*  If the source LOB will be written within the limits(from 1 to LOB length) of the dstination LOB. Then append the data from */         /*  dstination LOB before the "dstOffset", "amount" number of bytes from "srcLob" starting from "srcOffset" and the remaining */         /*  part of the dstination LOB after "dstOffset + amount". This behaviour is achieved by INSERT() function. */         /*  If the writing of the source LOB will start within the limits, but will end up exceeding the limit of the dstination LOB. */         /*  Then append the data from dstination LOB before the "dstOffset" and "amount" number of bytes from "srcLob" starting from "srcOffset". */         /*  If the writing of the source LOB will start out of the limits of the dstination LOB. Then append the dstination LOB with the */         /*  required number of spaces till the index of "dstOffset" and "amount" number of bytes from "srcLob" starting from "srcOffset". */         /*  NOTE: If "dstOffset" is greater than length of dstination-LOB then SUBSTR appends "offset - dstLobLen" white spaces to the */         /*        dstination LOB. But SUBSTRING appends only one white space. So we can't use SUBSTRING at places where we need to */         /*        append white spaces. */          IF dstOffset <= dstLength  THEN            IF dstOffset + bytesToCopy <= dstLength THEN            RETURN SYSIBM.SUBSTR(dstLob, 1, dstOffset - 1) CONCAT                       /* Appends data before "dstOffset" of the dstination LOB. */                   SYSIBM.SUBSTR(srcLob, srcOffset, bytesToCopy)  CONCAT                  /* Appends the required amount of source LOB. */                   SYSIBM.SUBSTR(dstLob, dstOffset + bytesToCopy);                      /* Appends data after "dstOffset + amount" of the dstination LOB. */            ELSE            RETURN SYSIBM.SUBSTR(dstLob, 1, dstOffset - 1) CONCAT                       /* Appends data before "dstOffset" of the dstination LOB. */                   SYSIBM.SUBSTR(srcLob, srcOffset, bytesToCopy);                         /* Appends the required amount of source LOB. */            END IF;         ELSE         RETURN  dstLob CONCAT                                                    /* Appends the dstination LOB. */                 REPEAT(CAST(BLOB(X'00') AS BLOB), dstOffset - dstLength - 1)     /* Appends extra zero's. */                 CONCAT SYSIBM.SUBSTR(srcLob, srcOffset, bytesToCopy);                    /* Appends the required amount of source LOB. */         END IF;               END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	FUNCTION  WRITE_TO_LOB(dstLob CLOB(10M), srcLob CLOB(10M), amount INTEGER, dstOffset INTEGER, srcOffset INTEGER) RETURNS CLOB(10M)       SPECIFIC DBMS_LOB_WRITE_TO_LOB       LANGUAGE SQL         BEGIN           DECLARE srcLength   INTEGER;           DECLARE dstLength  INTEGER;           DECLARE bytesToCopy INTEGER;                 SET srcLength = LENGTH(srcLob);           SET dstLength = LENGTH(dstLob);           SET bytesToCopy = DBMS_LOB.BYTESLEFT(srcLength, amount, srcOffset);         /*  If the source LOB will be written within the limits(from 1 to LOB length) of the dstination LOB. Then append the data from */         /*  dstination LOB before the "dstOffset", "amount" number of bytes from "srcLob" starting from "srcOffset" and the remaining */         /*  part of the dstination LOB after "dstOffset + amount". This behaviour is achieved by INSERT() function. */         /*  If the writing of the source LOB will start within the limits, but will end up exceeding the limit of the dstination LOB. */         /*  Then append the data from dstination LOB before the "dstOffset" and "amount" number of bytes from "srcLob" starting from "srcOffset". */         /*  If the writing of the source LOB will start out of the limits of the dstination LOB. Then append the dstination LOB with the */         /*  required number of spaces till the index of "dstOffset" and "amount" number of bytes from "srcLob" starting from "srcOffset". */         /*  NOTE: If "dstOffset" is greater than length of dstination-LOB then SUBSTR appends "offset - dstLobLen" white spaces to the */         /*        dstination LOB. But SUBSTRING appends only one white space. So we can't use SUBSTRING at places where we need to */         /*        append white spaces. */           IF dstOffset <= dstLength  THEN             IF dstOffset + bytesToCopy <= dstLength THEN               RETURN INSERT(dstLob, dstOffset, bytesToCopy, SUBSTRING(srcLob, srcOffset, bytesToCopy, CODEUNITS16), CODEUNITS16);            ELSE           RETURN SUBSTRING(dstLob, 1, dstOffset - 1, CODEUNITS16) CONCAT         /* Appends data before "dstOffset" of the dstination LOB. */                  SUBSTRING(srcLob, srcOffset, bytesToCopy, CODEUNITS16);           /* Appends the required amount of source LOB. */           END IF;           ELSE           RETURN  dstLob CONCAT                                                   /* Appends the dstination LOB. */                   REPEAT(CAST(' ' AS CLOB), dstOffset - dstLength - 1) CONCAT     /* Appends extra spaces. */                   SUBSTRING(srcLob, srcOffset, bytesToCopy, CODEUNITS16);          /* Appends the required amount of source LOB. */           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	PROCEDURE  "IMP_CONVERTTOBLOB"(INOUT DEST_LOB BLOB(10485760),
		SRC_CLOB CLOB(10485760),
		AMOUNT INTEGER,
		INOUT DEST_OFFSET INTEGER,
		INOUT SRC_OFFSET INTEGER,
		BLOB_CSID INTEGER,
		INOUT LANG_CONTEXT INTEGER,
		OUT WARNING INTEGER)
	SPECIFIC DBMS_LOB_IMP_CONVERTTOBLOB
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_lob_converttoblob';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	PROCEDURE  "IMP_CONVERTTOCLOB"(INOUT DEST_LOB CLOB(10485760),
		SRC_BLOB BLOB(10485760),
		AMOUNT INTEGER,
		INOUT DEST_OFFSET INTEGER,
		INOUT SRC_OFFSET INTEGER,
		BLOB_CSID INTEGER,
		INOUT LANG_CONTEXT INTEGER,
		OUT WARNING INTEGER)
	SPECIFIC DBMS_LOB_IMP_CONVERTTOCLOB
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_lob_converttoclob';

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	PROCEDURE  CHECK_DB_CSID(csid INTEGER, OUT isValid BOOLEAN)       SPECIFIC DBMS_LOB_CHECK_DB_CSID       LANGUAGE SQL         BEGIN           DECLARE stmt VARCHAR(200) DEFAULT             'SELECT value FROM sysibmadm.dbcfg WHERE name = ''codepage''';           DECLARE dbCsid INTEGER;           DECLARE C1 CURSOR FOR S1;                     SET isValid = TRUE;                     /* SELECT value INTO dbCsid FROM sysibmadm.dbcfg WHERE name = 'codepage'; */           IF csid <> DBMS_LOB.DEFAULT_CSID THEN             PREPARE S1 FROM stmt;             OPEN C1;             FETCH C1 INTO dbCsid;             CLOSE C1;                         IF csid IS NULL OR csid != dbCsid THEN               SET isValid = FALSE;             END IF;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" ADD
	PROCEDURE  VALIDATE_LENGTH(length1 INTEGER, length2 INTEGER, errorCode VARCHAR(10))       SPECIFIC DBMS_LOB_VALIDATE_LENGTH       LANGUAGE SQL         BEGIN ATOMIC           IF length1 > length2 THEN             /*             IF errorCode = '77560' THEN               SIGNAL SQLSTATE '77560' SET MESSAGE_TEXT = 'argument 2 is null, invalid, or out of range';             ELSEIF errorCode = '77926' THEN               SIGNAL SQLSTATE '77926' SET MESSAGE_TEXT = 'specified trim length is greater than current LOB value''s length';             ELSEIF errorCode = '77994' THEN               SIGNAL SQLSTATE '77560' SET MESSAGE_TEXT = 'source offset is beyond the end of the source LOB';             END IF;             */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -138, NULL );           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 BLOB(10M), lob_2 BLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_8       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user did not specify any offsets. */           /* Do not let any of the hardcoded offsets */           /* of 1 cause a -138 for a zero-length lob case */           IF (lob_1Len = 0) AND (lob_2Len = 0) THEN             RETURN 0;           ELSEIF (lob_1Len = 0) AND (lob_2Len > 0) THEN             RETURN -1;           ELSEIF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, DBMS_LOB.LOBMAXSIZE, 1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 BLOB(10M), lob_2 BLOB(10M), amount INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_7       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user did not specify any offsets. */           /* Do not let any of the hardcoded offsets */           /* of 1 cause a -138 for a zero-length lob case */           IF (lob_1Len = 0) AND (lob_2Len = 0) THEN             RETURN 0;           ELSEIF (lob_1Len = 0) AND (lob_2Len > 0) THEN             RETURN -1;           ELSEIF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, amount, 1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 BLOB(10M), lob_2 BLOB(10M), amount INTEGER, offset_1 INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_6       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user explicitly specified a lob_1 offset. */           /* If the second lob is zero length, the hardcoded */           /* value of offset 1 for the second lob will return */           /* sql0138. Instead, just return lob1 > than lob2 */           IF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, amount, offset_1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 BLOB(10M), lob_2 BLOB(10M), amount INTEGER, offset_1 INTEGER, offset_2 INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_5       LANGUAGE SQL         BEGIN           DECLARE lob_1Buffer        VARCHAR(32672) FOR BIT DATA;           DECLARE lob_2Buffer        VARCHAR(32672) FOR BIT DATA;           DECLARE lob_1Len           INTEGER;           DECLARE lob_2Len           INTEGER;           DECLARE lob_1EndPoint      BIGINT;           DECLARE lob_2EndPoint      BIGINT;           DECLARE lob_1BytesToRead   INTEGER;           DECLARE lob_2BytesToRead   INTEGER;           DECLARE lob_1Offset        BIGINT;           DECLARE lob_2Offset        BIGINT;           DECLARE bytesRead         BIGINT;           DECLARE bytesLeft         INTEGER;           DECLARE status            INTEGER DEFAULT 0;           DECLARE isFirstTime       INTEGER DEFAULT 1;                 IF lob_1 IS NULL OR              lob_2 IS NULL OR              amount IS NULL OR amount < 1 OR amount > DBMS_LOB.LOBMAXSIZE OR              offset_1 IS NULL OR offset_1 < 1 OR offset_1 > DBMS_LOB.LOBMAXSIZE OR              offset_2 IS NULL OR offset_2 < 1 OR offset_2 > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                 SET lob_1Offset = offset_1;           SET lob_2Offset = offset_2;           SET bytesRead = 0;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);         /*  Ending point for the offsets, the comparing will stop if any of the offsets of the LOB's will exceed that limit. */         /*  Casting to BIGINT is required otherwise it throws an " Arithmetic overflow" error if "offset + amount" exceeds "DBMS_LOB.LOBMAXSIZE". */           SET lob_1EndPoint = CAST(offset_1 AS BIGINT) + CAST(amount AS BIGINT);           SET lob_2EndPoint = CAST(offset_2 AS BIGINT) + CAST(amount AS BIGINT);         /*  BREAK if offsets have exceeded their end limits, or status is not zero(which means that LOB's are not equal) */         /*  NOTE: REPEAT(like do while loop in C) has not been used, because db2 does not support REPEAT loop in functions */         /*        which are declared as BEGIN ATOMIC. */           WHILE ((lob_1Offset <= lob_1Len AND lob_1Offset < lob_1EndPoint                   AND lob_2Offset <= lob_2Len AND lob_2Offset < lob_2EndPoint                   AND status = 0) OR isFirstTime = 1) DO                   SET isFirstTime = 0;           /*  Determine the amount of bytes to be read from the lob_1, LOB's are compared by fetching "DBMS_LOB.MAXBUFSIZE" bytes at one */           /*  go and then repeating the process.(If "DBMS_LOB.MAXBUFSIZE" bytes are not available, then the remaining bytes are fetched). */             SET bytesLeft = amount - bytesRead;                   IF bytesLeft <= DBMS_LOB.MAXBUFSIZE THEN               SET lob_1BytesToRead = bytesLeft;               SET lob_2BytesToRead = bytesLeft;             ELSE               SET lob_1BytesToRead = DBMS_LOB.MAXBUFSIZE;               SET lob_2BytesToRead = DBMS_LOB.MAXBUFSIZE;             END IF;           /* DBMS_LOB.READ accepts an integer offset, so casting is required. */             SET lob_1Buffer = DBMS_LOB.READ(lob_1, lob_1BytesToRead, CAST(lob_1Offset AS INTEGER));             SET lob_2Buffer = DBMS_LOB.READ(lob_2, lob_2BytesToRead, CAST(lob_2Offset AS INTEGER));           /*  If buffers were not equal, then set the appropriate status. */             IF lob_1Buffer > lob_2Buffer THEN               SET status = 1;             ELSEIF lob_1Buffer < lob_2Buffer THEN               SET status = -1;             END IF;                   SET bytesRead  = bytesRead + lob_1BytesToRead;             SET lob_1Offset = lob_1Offset + lob_1BytesToRead;             SET lob_2Offset = lob_2Offset + lob_2BytesToRead;           END WHILE;                 RETURN status;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 CLOB(10M), lob_2 CLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_4       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user did not specify any offsets. */           /* Do not let any of the hardcoded offsets */           /* of 1 cause a -138 for a zero-length lob case */           IF (lob_1Len = 0) AND (lob_2Len = 0) THEN             RETURN 0;           ELSEIF (lob_1Len = 0) AND (lob_2Len > 0) THEN             RETURN -1;           ELSEIF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, DBMS_LOB.LOBMAXSIZE, 1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 CLOB(10M), lob_2 CLOB(10M), amount INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_3       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user did not specify any offsets. */           /* Do not let any of the hardcoded offsets */           /* of 1 cause a -138 for a zero-length lob case */           IF (lob_1Len = 0) AND (lob_2Len = 0) THEN             RETURN 0;           ELSEIF (lob_1Len = 0) AND (lob_2Len > 0) THEN             RETURN -1;           ELSEIF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, amount, 1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 CLOB(10M), lob_2 CLOB(10M), amount INTEGER, offset_1 INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE_2       LANGUAGE SQL         BEGIN           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);           /* The user explicitly specified a lob_1 offset. */           /* If the second lob is zero length, the hardcoded */           /* value of offset 1 for the second lob will return */           /* sql0138. Instead, just return lob1 > than lob2 */           IF (lob_1Len > 0) AND (lob_2Len = 0) THEN             RETURN 1;           ELSE             RETURN DBMS_LOB.COMPARE(lob_1, lob_2, amount, offset_1, 1);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  COMPARE(lob_1 CLOB(10M), lob_2 CLOB(10M), amount INTEGER, offset_1 INTEGER, offset_2 INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_COMPARE       LANGUAGE SQL         BEGIN           DECLARE lob_1Buffer      VARCHAR(32672);           DECLARE lob_2Buffer      VARCHAR(32672);           DECLARE lob_1Len         INTEGER;           DECLARE lob_2Len         INTEGER;           DECLARE lob_1EndPoint    BIGINT;           DECLARE lob_2EndPoint    BIGINT;           DECLARE lob_1BytesToRead INTEGER;           DECLARE lob_2BytesToRead INTEGER;           DECLARE lob_1Offset      BIGINT;           DECLARE lob_2Offset      BIGINT;           DECLARE bytesRead       BIGINT;           DECLARE bytesLeft       INTEGER;           DECLARE status          INTEGER DEFAULT 0;           DECLARE isFirstTime     INTEGER DEFAULT 1;                 IF lob_1 IS NULL OR              lob_2 IS NULL OR              amount IS NULL OR amount < 1 OR amount > DBMS_LOB.LOBMAXSIZE OR              offset_1 IS NULL OR offset_1 < 1 OR offset_1 > DBMS_LOB.LOBMAXSIZE OR              offset_2 IS NULL OR offset_2 < 1 OR offset_2 > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                     SET lob_1Offset = offset_1;           SET lob_2Offset = offset_2;           SET bytesRead = 0;           SET lob_1Len = LENGTH(lob_1);           SET lob_2Len = LENGTH(lob_2);         /*  Ending point for the offsets, the comparing will stop if any of the offsets of the LOB's will exceed that limit. */         /*  Casting to BIGINT is required otherwise it throws an " Arithmetic overflow" error if "offset + amount" exceeds "DBMS_LOB.LOBMAXSIZE". */           SET lob_1EndPoint = CAST(offset_1 AS BIGINT) + CAST(amount AS BIGINT);           SET lob_2EndPoint = CAST(offset_2 AS BIGINT) + CAST(amount AS BIGINT);         /*  BREAK if offsets have exceeded their end limits, or status is not zero(which means that LOB's are not equal) */         /*  NOTE: REPEAT(like do while loop in C) has not been used, because db2 does not support REPEAT loop in functions */         /*        which are declared as BEGIN ATOMIC. */           WHILE ((lob_1Offset <= lob_1Len AND lob_1Offset < lob_1EndPoint                   AND lob_2Offset <= lob_2Len AND lob_2Offset < lob_2EndPoint                   AND status = 0) OR isFirstTime = 1) DO                   SET isFirstTime = 0;           /*  Determine the amount of characters to be read from the LOB_1, LOB's are compared by fetching "DBMS_LOB.MAXBUFSIZE" characters at one */           /*  go and then repeating the process.(If "DBMS_LOB.MAXBUFSIZE" characters are not available, then the remaining characters are fetched). */             SET bytesLeft = amount - bytesRead;                   IF bytesLeft <= DBMS_LOB.MAXBUFSIZE THEN               SET lob_1BytesToRead = bytesLeft;               SET lob_2BytesToRead = bytesLeft;             ELSE               SET lob_1BytesToRead = DBMS_LOB.MAXBUFSIZE;               SET lob_2BytesToRead = DBMS_LOB.MAXBUFSIZE;             END IF;           /* DBMS_LOB.READ accepts an integer offset, so casting is required. */             SET lob_1Buffer = DBMS_LOB.READ(lob_1, lob_1BytesToRead, CAST(lob_1Offset AS INTEGER));             SET lob_2Buffer = DBMS_LOB.READ(lob_2, lob_2BytesToRead, CAST(lob_2Offset AS INTEGER));           /*  If buffers were not equal, then set the appropriate status. */             IF lob_1Buffer > lob_2Buffer THEN               SET status = 1;             ELSEIF lob_1Buffer < lob_2Buffer THEN               SET status = -1;             END IF;                   SET bytesRead  = bytesRead + lob_1BytesToRead;             SET lob_1Offset = lob_1Offset + lob_1BytesToRead;             SET lob_2Offset = lob_2Offset + lob_2BytesToRead;           END WHILE;                 RETURN status;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  GETLENGTH(lob_loc BLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_GETLENGTH_2       LANGUAGE SQL         BEGIN           RETURN LENGTH(lob_loc);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  GETLENGTH(lob_loc CLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_GETLENGTH       LANGUAGE SQL         BEGIN           RETURN LENGTH(lob_loc, CODEUNITS16);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  GET_STORAGE_LIMIT() RETURNS INTEGER       SPECIFIC DBMS_LOB_GET_STORAGE_LIMIT       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.LOBMAXSIZE;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  GET_STORAGE_LIMIT(lob_loc BLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_GET_STORAGE_LIMIT_3       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.LOBMAXSIZE;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  GET_STORAGE_LIMIT(lob_loc CLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_GET_STORAGE_LIMIT_2       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.LOBMAXSIZE;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc BLOB(10M), pattern BLOB(32672)) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR_6       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.INSTR( lob_loc, pattern, 1, 1 );         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc BLOB(10M), pattern BLOB(32672), offset INTEGER ) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR_5       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.INSTR( lob_loc, pattern, offset, 1 );         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc BLOB(10M), pattern BLOB(32672), offset INTEGER, nth INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR_4       LANGUAGE SQL         BEGIN           DECLARE index      BIGINT;           DECLARE n          INTEGER;           DECLARE patternLen INTEGER;           DECLARE position   INTEGER;           DECLARE lobLength  INTEGER;                 IF lob_loc IS NULL OR              PATTERN IS NULL OR              offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE OR              nth IS NULL OR nth < 1 OR nth > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                     SET n = nth;           SET index = offset;           SET position = 0;           SET patternLen = LENGTH(pattern);           SET lobLength = LENGTH(lob_loc);                 WHILE (n > 0) DO             IF index > lobLength THEN               RETURN 0;             END IF;                   SET position = LOCATE(pattern, lob_loc, CAST(index AS INTEGER));           /*  Break before n reaches to zero if no occurrence of the pattern is found at any time. */             IF position = 0 THEN               RETURN  position;             END IF;           /*  Casting to BIGINT is required otherwise it throws an "Arithmetic overflow" error if "position + patternLen" exceeds "DBMS_LOB.LOBMAXSIZE". */             SET index = CAST(position AS BIGINT) + CAST(patternLen AS BIGINT);             SET n = n - 1;           END WHILE;                 RETURN position;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc CLOB(10M), pattern VARCHAR(32672) ) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR_3       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.INSTR( lob_loc, pattern, 1, 1 );         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc CLOB(10M), pattern VARCHAR(32672), offset INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR_2       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.INSTR( lob_loc, pattern, offset, 1 );         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  INSTR(lob_loc CLOB(10M), pattern VARCHAR(32672), offset INTEGER, nth INTEGER) RETURNS INTEGER       SPECIFIC DBMS_LOB_INSTR       LANGUAGE SQL         BEGIN           DECLARE index      BIGINT;           DECLARE n          INTEGER;           DECLARE patternLen INTEGER;           DECLARE position   INTEGER;           DECLARE lobLength  INTEGER;                     IF lob_loc IS NULL OR              PATTERN IS NULL OR              offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE OR              nth IS NULL OR nth < 1 OR nth > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                     SET n = nth;           SET index = offset;           SET position = offset;           SET patternLen = LENGTH(pattern);           SET lobLength = LENGTH(lob_loc);                 WHILE (n > 0) DO             IF index > lobLength THEN               RETURN 0;             END IF;                   SET position = LOCATE(pattern, lob_loc, CAST(index AS INTEGER), CODEUNITS16);           /*  Break before n reaches to zero if no occurrence of the pattern is found at any time. */             IF position = 0 THEN               RETURN  position;             END IF;           /*  Casting to BIGINT is required otherwise it throws an "Arithmetic overflow" error if "position + patternLen" exceeds "DBMS_LOB.LOBMAXSIZE". */             SET index = CAST(position AS BIGINT) + CAST(patternLen AS BIGINT);             SET n = n - 1;           END WHILE;                 RETURN position;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  ISOPEN(lob BLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_ISOPEN_2       LANGUAGE SQL         BEGIN           RETURN 1;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  ISOPEN(lob CLOB(10M)) RETURNS INTEGER       SPECIFIC DBMS_LOB_ISOPEN       LANGUAGE SQL         BEGIN           RETURN 1;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob BLOB(10M)) RETURNS BLOB(32767)       SPECIFIC DBMS_LOB_SUBSTR_6       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.SUBSTR(lob, DBMS_LOB.MAXBUFSIZE, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob BLOB(10M), amount INTEGER) RETURNS BLOB(32767)       SPECIFIC DBMS_LOB_SUBSTR_5       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.SUBSTR(lob, amount, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob BLOB(10M), amount INTEGER, offset INTEGER) RETURNS BLOB(32767)       SPECIFIC DBMS_LOB_SUBSTR_4       LANGUAGE SQL         BEGIN           DECLARE len       INTEGER;           DECLARE bytesLeft INTEGER;                 IF lob IS NULL OR              amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE OR              offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                 SET len = LENGTH(lob);                 IF offset > len THEN             RETURN NULL;           END IF;                 SET bytesLeft = DBMS_LOB.BYTESLEFT(len, amount, offset);                 RETURN SYSIBM.SUBSTR(lob, offset, bytesLeft);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob CLOB(10M)) RETURNS VARCHAR(32672)       SPECIFIC DBMS_LOB_SUBSTR_3       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.SUBSTR(lob, DBMS_LOB.MAXBUFSIZE, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob CLOB(10M), amount INTEGER) RETURNS VARCHAR(32672)       SPECIFIC DBMS_LOB_SUBSTR_2       LANGUAGE SQL         BEGIN           RETURN DBMS_LOB.SUBSTR(lob, amount, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	FUNCTION  SUBSTR(lob CLOB(10M), amount INTEGER, offset INTEGER) RETURNS VARCHAR(32672)       SPECIFIC DBMS_LOB_SUBSTR       LANGUAGE SQL         BEGIN           DECLARE len       INTEGER;           DECLARE bytesLeft INTEGER;                 IF lob IS NULL OR              amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE OR              offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             RETURN NULL;           END IF;                 SET len = LENGTH(lob);                 IF offset > len THEN             RETURN NULL;           END IF;                 SET bytesLeft = DBMS_LOB.BYTESLEFT(len, amount, offset);                 RETURN SUBSTRING(lob, offset, bytesLeft, CODEUNITS16);               END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  APPEND_BLOB(INOUT dest_lob BLOB(10M), src_lob BLOB(10M))       SPECIFIC DBMS_LOB_APPEND_BLOB         BEGIN                 IF DEST_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.APPEND_BLOB', 'DEST_LOB' );   ELSEIF SRC_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.APPEND_BLOB', 'SRC_LOB' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.NOVALUE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, DBMS_LOB.NOVALUE, 'DBMS_LOB.APPEND_BLOB', 'DBMS_LOB.NOVALUE' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (DBMS_LOB.NOVALUE + 1), 'DBMS_LOB.APPEND_BLOB', 'DBMS_LOB.NOVALUE' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (DBMS_LOB.NOVALUE + 2), 'DBMS_LOB.APPEND_BLOB', 'DBMS_LOB.NOVALUE' );   END IF;                   SET dest_lob = dest_lob CONCAT src_lob;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  APPEND_CLOB(INOUT dest_lob CLOB(10M), src_lob CLOB(10M))       SPECIFIC DBMS_LOB_APPEND_CLOB         BEGIN                 IF DEST_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.APPEND_CLOB', 'DEST_LOB' );   ELSEIF SRC_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.APPEND_CLOB', 'SRC_LOB' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.NOVALUE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, DBMS_LOB.NOVALUE, 'DBMS_LOB.APPEND_CLOB', 'DBMS_LOB.NOVALUE' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (DBMS_LOB.NOVALUE + 1), 'DBMS_LOB.APPEND_CLOB', 'DBMS_LOB.NOVALUE' );   ELSEIF DBMS_LOB.NOVALUE IS NULL OR DBMS_LOB.NOVALUE < 1 OR DBMS_LOB.NOVALUE > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (DBMS_LOB.NOVALUE + 2), 'DBMS_LOB.APPEND_CLOB', 'DBMS_LOB.NOVALUE' );   END IF;                   SET dest_lob = dest_lob CONCAT src_lob;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  CLOSE_BLOB(lob_loc BLOB(10M))       SPECIFIC DBMS_LOB_CLOSE_BLOB       LANGUAGE SQL         BEGIN         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  CLOSE_CLOB(lob_loc CLOB(10M))       SPECIFIC DBMS_LOB_CLOSE_CLOB       LANGUAGE SQL         BEGIN         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  CONVERTTOBLOB(INOUT dest_lob BLOB(10M), src_clob CLOB(10M), amount INTEGER, INOUT dest_offset INTEGER, INOUT src_offset INTEGER, blob_csid INTEGER, INOUT lang_context INTEGER, OUT warning INTEGER)       SPECIFIC DBMS_LOB_CONVERTTOBLOB         BEGIN           DECLARE srcLength   INTEGER;           DECLARE amountToRead INTEGER;           DECLARE isValidCSID BOOLEAN;                     SET warning = DBMS_LOB.NO_WARNING;                     IF amount IS NULL THEN             SET amount = DBMS_LOB.LOBMAXSIZE;           END IF;                     IF dest_offset IS NULL OR dest_offset = 0 THEN             SET dest_offset = 1;           END IF;                     IF src_offset IS NULL OR src_offset = 0 THEN             SET src_offset = 1;           END IF;                     IF src_clob IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_UTILITY.CONVERTTOCLOB', 'SRC_CLOB' );           ELSEIF amount < 0 OR amount > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_UTILITY.CONVERTTOCLOB', 'AMOUNT' );           ELSEIF dest_offset < 1 OR dest_offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '4', 'DBMS_UTILITY.CONVERTTOCLOB', 'DEST_OFFSET' );           ELSEIF src_offset < 1 OR src_offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '5', 'DBMS_UTILITY.CONVERTTOCLOB', 'SRC_OFFSET' );           ELSEIF blob_csid IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '6', 'DBMS_UTILITY.CONVERTTOCLOB', 'BLOB_CSID' );           ELSEIF lang_context IS NULL OR lang_context <> DBMS_LOB.DEFAULT_LANG_CTX THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '7', 'DBMS_UTILITY.CONVERTTOCLOB', 'LANG_CONTEXT' );           END IF;                     /*  If the given BLOB_CSID is different than the CSID of the database, throw an error. */           CALL DBMS_LOB.CHECK_DB_CSID(blob_csid, isValidCSID);           IF isValidCSID = FALSE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '6', 'DBMS_UTILITY.CONVERTTOCLOB', 'BLOB_CSID' );           END IF;                     IF amount <> 0 THEN             SET srcLength = LENGTH(src_clob);             /*  If the given source offset is greater than source total length, throw an error. */             CALL DBMS_LOB.VALIDATE_LENGTH(src_offset, srcLength, '77994');                         SET amountToRead = DBMS_LOB.BYTESLEFT(srcLength, amount, src_offset);                         /* SET dest_lob = DBMS_LOB.WRITE_TO_LOB(dest_lob, CAST(src_clob AS BLOB), amount, dest_offset, src_offset); */             CALL DBMS_LOB.IMP_CONVERTTOBLOB(dest_lob, src_clob, amountToRead, dest_offset, src_offset, blob_csid, lang_context, warning);                         /* SET THE OUT parameters */             SET dest_offset = dest_offset + amountToRead;             SET src_offset = src_offset + amountToRead;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  CONVERTTOCLOB(INOUT dest_lob CLOB(10M), src_blob BLOB(10M), amount INTEGER, INOUT dest_offset INTEGER, INOUT src_offset INTEGER, blob_csid INTEGER, INOUT lang_context INTEGER, OUT warning INTEGER)       SPECIFIC DBMS_LOB_CONVERTTOCLOB         BEGIN           DECLARE srcLength   INTEGER;           DECLARE amountToRead INTEGER;           DECLARE isValidCSID BOOLEAN;                     SET warning = DBMS_LOB.NO_WARNING;                     IF amount IS NULL THEN             SET amount = DBMS_LOB.LOBMAXSIZE;           END IF;                     IF dest_offset IS NULL OR dest_offset = 0 THEN             SET dest_offset = 1;           END IF;                     IF src_offset IS NULL OR src_offset = 0 THEN             SET src_offset = 1;           END IF;                     IF src_blob IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_UTILITY.CONVERTTOCLOB', 'SRC_BLOB' );           ELSEIF amount < 0 OR amount > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_UTILITY.CONVERTTOCLOB', 'AMOUNT' );           ELSEIF dest_offset < 1 OR dest_offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '4', 'DBMS_UTILITY.CONVERTTOCLOB', 'DEST_OFFSET' );           ELSEIF src_offset < 1 OR src_offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '5', 'DBMS_UTILITY.CONVERTTOCLOB', 'SRC_OFFSET' );           ELSEIF blob_csid IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '6', 'DBMS_UTILITY.CONVERTTOCLOB', 'BLOB_CSID' );           ELSEIF lang_context IS NULL OR lang_context <> DBMS_LOB.DEFAULT_LANG_CTX THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '7', 'DBMS_UTILITY.CONVERTTOCLOB', 'LANG_CONTEXT' );           END IF;                     /*  If the given BLOB_CSID is different than the CSID of the database, throw an error. */           CALL DBMS_LOB.CHECK_DB_CSID(blob_csid, isValidCSID);           IF isValidCSID = FALSE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '6', 'DBMS_UTILITY.CONVERTTOCLOB', 'BLOB_CSID' );           END IF;                     IF amount <> 0 THEN             SET srcLength = LENGTH(src_blob);                         /*  If the given source offset is greater than source total length, throw an error. */             CALL DBMS_LOB.VALIDATE_LENGTH(src_offset, srcLength, '77994');                         SET amountToRead = DBMS_LOB.BYTESLEFT(srcLength, amount, src_offset);                         /* SET dest_lob = DBMS_LOB.WRITE_TO_LOB(dest_lob, CAST(src_blob AS VARCHAR(32672) FOR MIXED DATA), amount, dest_offset, src_offset); */             CALL DBMS_LOB.IMP_CONVERTTOCLOB(dest_lob, src_blob, amountToRead, dest_offset, src_offset, blob_csid, lang_context, warning);                         /* SET THE OUT parameters */             SET dest_offset = dest_offset + amountToRead;             SET src_offset = src_offset + amountToRead;           END IF;        END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  COPY_BLOB(INOUT dest_lob BLOB(10M), src_lob BLOB(10M), amount INTEGER, dest_offset INTEGER DEFAULT 1, src_offset INTEGER DEFAULT 1)       SPECIFIC DBMS_LOB_COPY_BLOB         BEGIN               IF DEST_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.COPY_BLOB', 'DEST_LOB' );   ELSEIF SRC_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.COPY_BLOB', 'SRC_LOB' );   ELSEIF AMOUNT IS NULL OR AMOUNT < 1 OR AMOUNT > DBMS_LOB.MAXBUFSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, 3, 'DBMS_LOB.COPY_BLOB', 'AMOUNT' );   ELSEIF DEST_OFFSET IS NULL OR DEST_OFFSET < 1 OR DEST_OFFSET > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (3 + 1), 'DBMS_LOB.COPY_BLOB', 'DEST_OFFSET' );   ELSEIF SRC_OFFSET IS NULL OR SRC_OFFSET < 1 OR SRC_OFFSET > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (3 + 2), 'DBMS_LOB.COPY_BLOB', 'SRC_OFFSET' );   END IF;                 SET dest_lob = DBMS_LOB.WRITE_TO_LOB(dest_lob, src_lob, amount, dest_offset, src_offset);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  COPY_CLOB(INOUT dest_lob CLOB(10M), src_lob CLOB(10M), amount INTEGER, dest_offset INTEGER DEFAULT 1, src_offset INTEGER DEFAULT 1)       SPECIFIC DBMS_LOB_COPY_CLOB         BEGIN               IF DEST_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.COPY_CLOB', 'DEST_LOB' );   ELSEIF SRC_LOB IS NULL THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.COPY_CLOB', 'SRC_LOB' );   ELSEIF AMOUNT IS NULL OR AMOUNT < 1 OR AMOUNT > DBMS_LOB.MAXBUFSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, 3, 'DBMS_LOB.COPY_CLOB', 'AMOUNT' );   ELSEIF DEST_OFFSET IS NULL OR DEST_OFFSET < 1 OR DEST_OFFSET > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (3 + 1), 'DBMS_LOB.COPY_CLOB', 'DEST_OFFSET' );   ELSEIF SRC_OFFSET IS NULL OR SRC_OFFSET < 1 OR SRC_OFFSET > DBMS_LOB.LOBMAXSIZE THEN     CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, (3 + 2), 'DBMS_LOB.COPY_CLOB', 'SRC_OFFSET' );   END IF;                 SET dest_lob = DBMS_LOB.WRITE_TO_LOB(dest_lob, src_lob, amount, dest_offset, src_offset);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  ERASE_BLOB(INOUT lob_loc BLOB(10M), INOUT amount INTEGER, offset INTEGER DEFAULT 1)       SPECIFIC DBMS_LOB_ERASE_BLOB         BEGIN           DECLARE len INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.ERASE_BLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.ERASE_BLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.ERASE_BLOB', 'OFFSET' );           END IF;                 SET len = LENGTH(lob_loc);         /* Only erase if the offset is within the limits(from 1 to - LOB length) of the destination LOB. */           IF offset <= len THEN             SET amount = DBMS_LOB.BYTESLEFT(len, amount, offset);             SET lob_loc = DBMS_LOB.WRITE_TO_LOB(lob_loc, REPEAT(CAST(BLOB(X'00') AS BLOB), amount), amount, offset, 1);           ELSE             SET amount = 0;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  ERASE_CLOB(INOUT lob_loc CLOB(10M), INOUT amount INTEGER, offset INTEGER DEFAULT 1)       SPECIFIC DBMS_LOB_ERASE_CLOB         BEGIN                 DECLARE len INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.ERASE_CLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.ERASE_CLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.ERASE_CLOB', 'OFFSET' );           END IF;                 SET len = LENGTH(lob_loc);         /* Only erase if the offset is within the limits(from 1 to LOB length) of the destination LOB. */           IF offset <= len THEN             SET amount = DBMS_LOB.BYTESLEFT(len, amount, offset);             SET lob_loc = DBMS_LOB.WRITE_TO_LOB(lob_loc, REPEAT(CAST(' ' AS CLOB), amount), amount, offset, 1);           ELSE             SET amount = 0;           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  OPEN_BLOB(lob_loc BLOB(10M), open_mode INTEGER)       SPECIFIC DBMS_LOB_OPEN_BLOB       LANGUAGE SQL         BEGIN         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  OPEN_CLOB(lob_loc CLOB(10M), open_mode INTEGER)       SPECIFIC DBMS_LOB_OPEN_CLOB       LANGUAGE SQL         BEGIN           END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  READ_BLOB(lob_loc BLOB(10M), INOUT amount INTEGER, offset INTEGER, OUT buffer BLOB(32767))       SPECIFIC DBMS_LOB_READ_BLOB       MODIFIES SQL DATA         BEGIN           DECLARE len INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.READ_BLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.READ_BLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.READ_BLOB', 'OFFSET' );           END IF;                 SET len = LENGTH(lob_loc);         /*  If the given offset is greater than source total length of LOB, throw an error. */           IF (offset > len) THEN             /* SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'no data found.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -138, NULL );           ELSE             SET amount = DBMS_LOB.BYTESLEFT(len, amount, offset);             SET buffer = SYSIBM.SUBSTR(lob_loc, offset, amount);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  READ_CLOB(lob_loc CLOB(10M), INOUT amount INTEGER, offset INTEGER, OUT buffer VARCHAR(32672))       SPECIFIC DBMS_LOB_READ_CLOB       LANGUAGE SQL       MODIFIES SQL DATA         BEGIN           DECLARE len INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.READ_CLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.READ_CLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.READ_CLOB', 'OFFSET' );           END IF;                 SET len = SYSIBM.CHAR_LENGTH(lob_loc, CODEUNITS16);         /*  If the given offset is greater than source total length of LOB, throw an error. */           IF (offset > len) THEN             /* SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'no data found.'; */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -138, NULL );           ELSE             SET amount = DBMS_LOB.BYTESLEFT(len, amount, offset);             SET buffer = SUBSTRING(lob_loc, offset, amount, CODEUNITS16);           END IF;         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  TRIM_BLOB(INOUT lob_loc BLOB(10M), newLen INTEGER)       SPECIFIC DBMS_LOB_TRIM_BLOB         BEGIN           DECLARE lobLen INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.TRIM_BLOB', 'LOB_LOC' );           ELSEIF newLen IS NULL OR newLen < 0 OR newLen > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.TRIM_BLOB', 'NEWLEN' );           END IF;                 SET lobLen = LENGTH(lob_loc);         /*  If the newLength of the BLOB is greater than the old one. Throw an error. */           CALL DBMS_LOB.VALIDATE_LENGTH(newLen, lobLen, '77926');                 SET lob_loc = SYSIBM.SUBSTR(lob_loc, 1, newLen);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  TRIM_CLOB(INOUT lob_loc CLOB(10M), newLen INTEGER)       SPECIFIC DBMS_LOB_TRIM_CLOB         BEGIN           DECLARE lobLen INTEGER;                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.TRIM_CLOB', 'LOB_LOC' );           ELSEIF newLen IS NULL OR newLen < 0 OR newLen > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.TRIM_CLOB', 'NEWLEN' );           END IF;                 SET lobLen = LENGTH(lob_loc);         /*  If the "newLength" of the CLOB is greater than the old one. Throw an error. */           CALL DBMS_LOB.VALIDATE_LENGTH(newLen, lobLen, '77926');                     SET lob_loc = SUBSTRING(lob_loc,1, newLen, CODEUNITS16);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  WRITEAPPEND_BLOB(INOUT lob_loc BLOB(10M), amount INTEGER, buffer BLOB(32767))       SPECIFIC DBMS_LOB_WRITEAPPEND_BLOB         BEGIN           IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.WRITEAPPEND_BLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > LENGTH(buffer) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.WRITEAPPEND_BLOB', 'AMOUNT' );           ELSEIF buffer IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.WRITEAPPEND_BLOB', 'BUFFER' );           END IF;                     SET lob_loc = lob_loc CONCAT SYSIBM.SUBSTR(buffer, 1, amount);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  WRITEAPPEND_CLOB(INOUT lob_loc CLOB(10M), amount INTEGER, buffer VARCHAR(32672))       SPECIFIC DBMS_LOB_WRITEAPPEND_CLOB         BEGIN           IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.WRITEAPPEND_CLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > LENGTH(buffer) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.WRITEAPPEND_CLOB', 'AMOUNT' );           ELSEIF buffer IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.WRITEAPPEND_CLOB', 'BUFFER' );           END IF;                     SET lob_loc = lob_loc CONCAT SUBSTRING(buffer, 1, amount, CODEUNITS16);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  WRITE_BLOB(INOUT lob_loc BLOB(10M), amount INTEGER, offset INTEGER, buffer BLOB(32767))       SPECIFIC DBMS_LOB_WRITE_BLOB         BEGIN                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.WRITE_BLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.WRITE_BLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.WRITE_BLOB', 'OFFSET' );           END IF;               /*  If the amount to be written is greater than the total length of the buffer. */           IF (buffer IS NULL) THEN             CALL DBMS_LOB.VALIDATE_LENGTH(amount, 0, '77560');           ELSE             CALL DBMS_LOB.VALIDATE_LENGTH(amount, LENGTH(buffer), '77560');           END IF;                 SET lob_loc = DBMS_LOB.WRITE_TO_LOB(lob_loc, buffer, amount, offset, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_LOB" PUBLISH
	PROCEDURE  WRITE_CLOB(INOUT lob_loc CLOB(10M), amount INTEGER, offset INTEGER, buffer VARCHAR(32672))       SPECIFIC DBMS_LOB_WRITE_CLOB         BEGIN                 IF lob_loc IS NULL THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBMS_LOB.WRITE_CLOB', 'LOB_LOC' );           ELSEIF amount IS NULL OR amount < 1 OR amount > DBMS_LOB.MAXBUFSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_LOB.WRITE_CLOB', 'AMOUNT' );           ELSEIF offset IS NULL OR offset < 1 OR offset > DBMS_LOB.LOBMAXSIZE THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_LOB.WRITE_CLOB', 'OFFSET' );           END IF;                     /*  If the amount to be written is greater than the total length of the buffer. */           IF (buffer IS NULL) THEN             CALL DBMS_LOB.VALIDATE_LENGTH(amount, 0, '77560');           ELSE             CALL DBMS_LOB.VALIDATE_LENGTH(amount, LENGTH(buffer), '77560');           END IF;                 SET lob_loc = DBMS_LOB.WRITE_TO_LOB(lob_loc, buffer, amount, offset, 1);         END;

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" ADD
	PROCEDURE  "MY_SYS_INIT"()
	SPECIFIC DBMS_OUTPUT_MY_SYS_INIT
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_sys_init';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "DISABLE"()
	SPECIFIC DBMS_OUTPUT_DISABLE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_disable';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "ENABLE"(BUFFER_SIZE INTEGER)
	SPECIFIC DBMS_OUTPUT_ENABLE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_enable';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "GET_LINE"(OUT LINE VARCHAR(32672),
		OUT STATUS INTEGER)
	SPECIFIC DBMS_OUTPUT_GET_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_get_line';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "NEW_LINE"()
	SPECIFIC DBMS_OUTPUT_NEW_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_new_line';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "PUT"(ITEM VARCHAR(32672))
	SPECIFIC DBMS_OUTPUT_PUT
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_put_varchar2';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  "PUT_LINE"(ITEM VARCHAR(32672))
	SPECIFIC DBMS_OUTPUT_PUT_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_output_put_line_varchar2';

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  ENABLE()       SPECIFIC DBMS_OUTPUT_ENABLE_2       BEGIN         CALL DBMS_OUTPUT.ENABLE(NULL);       END;

ALTER MODULE "SYSIBMADM"."DBMS_OUTPUT" PUBLISH
	PROCEDURE  GET_LINES( OUT lines DBMS_OUTPUT.CHARARR, INOUT numlines INT )       SPECIFIC DBMS_OUTPUT_GET_LINES       READS SQL DATA       BEGIN         DECLARE line        VARCHAR(32672);         DECLARE status      INT;         DECLARE numlinesMax INT;                 set numlinesMax = numlines;         set numlines = 0;                 IF numlinesMax > 0 THEN           CALL DBMS_OUTPUT.GET_LINE( line, status );           WHILE status = 0 and numlines < numlinesMax DO             SET numlines = numlines + 1;             SET lines[numlines] = line;             CALL DBMS_OUTPUT.GET_LINE( line, status );           END WHILE;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "CREATE_PIPE"(PIPENAME VARCHAR(128))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_CREATE_PIPE_3
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "CREATE_PIPE"(PIPENAME VARCHAR(128),
		MAXPIPESIZE INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_CREATE_PIPE_2
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "CREATE_PIPE"(PIPENAME VARCHAR(128),
		MAXPIPESIZE INTEGER,
		PRIVATE SMALLINT)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_CREATE_PIPE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "NEXT_ITEM_TYPE"()
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_NEXT_ITEM_TYPE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "PACK_MESSAGE"(INTEGER)
	RETURNS INTEGER
	LANGUAGE 
	SPECIFIC DBMS_PIPE_PACK_MESSAGE_3
	FENCED THREADSAFE
	READS SQL DATA
	NO EXTERNAL ACTION
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "PACK_MESSAGE"(ITEM DATE)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_PACK_MESSAGE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "PACK_MESSAGE"(ITEM DECFLOAT(34))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_PACK_MESSAGE_2
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "PACK_MESSAGE"(ITEM VARCHAR(4096))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_PACK_MESSAGE_4
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "RECEIVE_MESSAGE"(PIPENAME VARCHAR(128))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_RECEIVE_MESSAGE_2
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "RECEIVE_MESSAGE"(PIPENAME VARCHAR(128),
		TIMEOUT INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_RECEIVE_MESSAGE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "REMOVE_PIPE"(PIPENAME VARCHAR(128))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_REMOVE_PIPE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "SEND_MESSAGE"(PIPENAME VARCHAR(128))
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_SEND_MESSAGE_3
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "SEND_MESSAGE"(PIPENAME VARCHAR(128),
		TIMEOUT INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_SEND_MESSAGE_2
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "SEND_MESSAGE"(PIPENAME VARCHAR(128),
		TIMEOUT INTEGER,
		MAXPIPESIZE INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC DBMS_PIPE_SEND_MESSAGE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  "UNIQUE_SESSION_NAME"()
	RETURNS VARCHAR(128)
	LANGUAGE C
	SPECIFIC DBMS_PIPE_UNIQUE_SESSION_NAME
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	FUNCTION  CREATE_PIPE(pipename VARCHAR(128), maxpipesize INTEGER, private BOOLEAN)        RETURNS INTEGER       SPECIFIC DBMS_PIPE_CREATE_PIPE_4       LANGUAGE SQL       BEGIN         RETURN DBMS_PIPE.CREATE_PIPE(pipename, maxpipesize, CAST( CASE WHEN private IS NULL THEN NULL WHEN private = true THEN 1 ELSE 0 END AS SMALLINT));       END;

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "PACK_MESSAGE_RAW"(ITEM BLOB(4096))
	SPECIFIC DBMS_PIPE_PACK_MESSAGE_RAW
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_pack_message_raw';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "PURGE"(PIPENAME VARCHAR(128))
	SPECIFIC DBMS_PIPE_PURGE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_purge';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "RESET_BUFFER"()
	SPECIFIC DBMS_PIPE_RESET_BUFFER
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_reset_buffer';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "UNPACK_MESSAGE"(OUT ITEM VARCHAR(4096))
	SPECIFIC DBMS_PIPE_UNPACK_MESSAGE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_unpack_message_char';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "UNPACK_MESSAGE_CHAR"(OUT ITEM VARCHAR(4096))
	SPECIFIC DBMS_PIPE_UNPACK_MESSAGE_CHAR
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_unpack_message_char';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "UNPACK_MESSAGE_DATE"(OUT ITEM DATE)
	SPECIFIC DBMS_PIPE_UNPACK_MESSAGE_DATE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_unpack_message_date';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "UNPACK_MESSAGE_NUMBER"(OUT ITEM DECFLOAT(34))
	SPECIFIC DBMS_PIPE_UNPACK_MESSAGE_NUMBER
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_unpack_message_number';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  "UNPACK_MESSAGE_RAW"(OUT ITEM BLOB(4096))
	SPECIFIC DBMS_PIPE_UNPACK_MESSAGE_RAW
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_pipe_unpack_message_raw';

ALTER MODULE "SYSIBMADM"."DBMS_PIPE" PUBLISH
	PROCEDURE  UNPACK_MESSAGE_INT(OUT item INTEGER)       SPECIFIC DBMS_PIPE_UNPACK_MESSAGE_INT       DYNAMIC RESULT SETS 0       LANGUAGE SQL       BEGIN         CALL DBMS_PIPE.UNPACK_MESSAGE_NUMBER( item );       END;

ALTER MODULE "SYSIBMADM"."DBMS_SQL" ADD
	PROCEDURE  "IMP_DESCRIBE_COLUMNS"(C INTEGER,
		OUT COL_CNT INTEGER)
	SPECIFIC DBMS_SQL_IMP_DESCRIBE_COLUMNS
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_describe_columns';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_BLOB"(C INTEGER,
		NAME VARCHAR(128),
		VALUE BLOB(10485760))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_BLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_blob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_CHAR"(C INTEGER,
		NAME VARCHAR(128),
		VALUE CHAR(254))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_CHAR_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_char_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_CHAR"(C INTEGER,
		NAME VARCHAR(128),
		VALUE CHAR(254),
		OUT_VALUE_SIZE INTEGER)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_CHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_char';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_CLOB"(C INTEGER,
		NAME VARCHAR(128),
		VALUE CLOB(10485760))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_CLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_clob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_DATE"(C INTEGER,
		NAME VARCHAR(128),
		VALUE DATE)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_DATE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_date';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_DOUBLE"(C INTEGER,
		NAME VARCHAR(128),
		VALUE DOUBLE)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_DOUBLE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_double';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_INT"(C INTEGER,
		NAME VARCHAR(128),
		VALUE INTEGER)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_INT
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_int';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_NUMBER"(C INTEGER,
		NAME VARCHAR(128),
		VALUE DECFLOAT(34))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_NUMBER
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_number';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_RAW"(C INTEGER,
		NAME VARCHAR(128),
		VALUE BLOB(32767))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_RAW_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_raw_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_RAW"(C INTEGER,
		NAME VARCHAR(128),
		VALUE BLOB(32767),
		OUT_VALUE_SIZE INTEGER)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_RAW
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_raw';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_TIMESTAMP"(C INTEGER,
		NAME VARCHAR(128),
		VALUE TIMESTAMP)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_TIMESTAMP
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_timestamp';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_VARCHAR"(C INTEGER,
		NAME VARCHAR(128),
		VALUE VARCHAR(32672))
	SPECIFIC DBMS_SQL_BIND_VARIABLE_VARCHAR_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_varchar_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "BIND_VARIABLE_VARCHAR"(C INTEGER,
		NAME VARCHAR(128),
		VALUE VARCHAR(32672),
		OUT_VALUE_SIZE INTEGER)
	SPECIFIC DBMS_SQL_BIND_VARIABLE_VARCHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_bind_variable_varchar';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "CLOSE_CURSOR"(INOUT C INTEGER)
	SPECIFIC DBMS_SQL_CLOSE_CURSOR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_close_cursor';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_BLOB"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE BLOB(10485760))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_BLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_blob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_CHAR"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE CHAR(254))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_CHAR_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_char_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_CHAR"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE CHAR(254),
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_CHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_char';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_CLOB"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE CLOB(10485760))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_CLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_clob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_DATE"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DATE)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_DATE_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_date_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_DATE"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DATE,
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_DATE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_date';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_DOUBLE"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DOUBLE)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_DOUBLE_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_double_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_DOUBLE"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DOUBLE,
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_DOUBLE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_double';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_INT"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_INT_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_int_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_INT"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE INTEGER,
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_INT
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_int';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_LONG"(C INTEGER,
		POSITION INTEGER,
		LENGTH INTEGER,
		OFFSET INTEGER,
		OUT VALUE CLOB(32760),
		OUT VALUE_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_LONG
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_long';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_NUMBER"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DECFLOAT(34))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_NUMBER_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_number_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_NUMBER"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE DECFLOAT(34),
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_NUMBER
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_number';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_RAW"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE BLOB(32767))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_RAW_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_raw_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_RAW"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE BLOB(32767),
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_RAW
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_raw';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_TIMESTAMP"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE TIMESTAMP)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_TIMESTAMP_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_timestamp_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_TIMESTAMP"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE TIMESTAMP,
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_TIMESTAMP
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_timestamp';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_VARCHAR"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE VARCHAR(32672))
	SPECIFIC DBMS_SQL_COLUMN_VALUE_VARCHAR_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_varchar_3Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "COLUMN_VALUE_VARCHAR"(C INTEGER,
		POSITION INTEGER,
		OUT VALUE VARCHAR(32672),
		OUT COLUMN_ERROR INTEGER,
		OUT ACTUAL_LENGTH INTEGER)
	SPECIFIC DBMS_SQL_COLUMN_VALUE_VARCHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_column_value_varchar';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_BLOB"(C INTEGER,
		POSITION INTEGER,
		COLUMN BLOB(10485760))
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_BLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_blob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_CHAR"(C INTEGER,
		POSITION INTEGER,
		COLUMN CHAR(254),
		COLUMN_SIZE INTEGER)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_CHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_char';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_CLOB"(C INTEGER,
		POSITION INTEGER,
		COLUMN CLOB(10485760))
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_CLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_clob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_DATE"(C INTEGER,
		POSITION INTEGER,
		COLUMN DATE)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_DATE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_date';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_DOUBLE"(C INTEGER,
		POSITION INTEGER,
		COLUMN DOUBLE)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_DOUBLE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_double';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_INT"(C INTEGER,
		POSITION INTEGER,
		COLUMN INTEGER)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_INT
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_int';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_LONG"(C INTEGER,
		POSITION INTEGER)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_LONG
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_long';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_NUMBER"(C INTEGER,
		POSITION INTEGER,
		COLUMN DECFLOAT(34))
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_NUMBER
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_number';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_RAW"(C INTEGER,
		POSITION INTEGER,
		COLUMN BLOB(32767),
		COLUMN_SIZE INTEGER)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_RAW
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_raw';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_TIMESTAMP"(C INTEGER,
		POSITION INTEGER,
		COLUMN TIMESTAMP)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_TIMESTAMP
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_timestamp';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "DEFINE_COLUMN_VARCHAR"(C INTEGER,
		POSITION INTEGER,
		COLUMN VARCHAR(32672),
		COLUMN_SIZE INTEGER)
	SPECIFIC DBMS_SQL_DEFINE_COLUMN_VARCHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_define_column_varchar';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "EXECUTE"(C INTEGER,
		OUT RET INTEGER)
	SPECIFIC DBMS_SQL_EXECUTE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_execute';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "EXECUTE_AND_FETCH"(C INTEGER,
		EXACT INTEGER,
		OUT RET INTEGER)
	SPECIFIC DBMS_SQL_EXECUTE_AND_FETCH
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_execute_and_fetch';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "EXECUTE_AND_FETCH"(C INTEGER,
		OUT RET INTEGER)
	SPECIFIC DBMS_SQL_EXECUTE_AND_FETCH_2
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2packlib!sqleml_dbms_sql_execute_and_fetch_2Params';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "FETCH_ROWS"(C INTEGER,
		OUT RET INTEGER)
	SPECIFIC DBMS_SQL_FETCH_ROWS
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_fetch_rows';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "IS_OPEN"(C INTEGER,
		OUT RET INTEGER)
	SPECIFIC DBMS_SQL_IS_OPEN
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_is_open';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "LAST_ROW_COUNT"(OUT RET INTEGER)
	SPECIFIC DBMS_SQL_LAST_ROW_COUNT
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_last_row_count';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "OPEN_CURSOR"(OUT C INTEGER)
	SPECIFIC DBMS_SQL_OPEN_CURSOR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_open_cursor';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "PARSE"(C INTEGER,
		STATEMENT VARCHAR(32672),
		LANGUAGE_FLAG INTEGER)
	SPECIFIC DBMS_SQL_PARSE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_parse';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_BLOB"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE BLOB(10485760))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_BLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_blob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_CHAR"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE CHAR(254))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_CHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_char';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_CLOB"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE CLOB(10485760))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_CLOB
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_clob';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_DATE"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE DATE)
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_DATE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_date';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_DOUBLE"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE DOUBLE)
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_DOUBLE
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_double';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_INT"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE INTEGER)
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_INT
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_int';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_NUMBER"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE DECFLOAT(34))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_NUMBER
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_number';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_RAW"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE BLOB(32767))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_RAW
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_raw';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_TIMESTAMP"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE TIMESTAMP)
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_TIMESTAMP
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_timestamp';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  "VARIABLE_VALUE_VARCHAR"(C INTEGER,
		NAME VARCHAR(128),
		OUT VALUE VARCHAR(32672))
	SPECIFIC DBMS_SQL_VARIABLE_VALUE_VARCHAR
	MODIFIES SQL DATA
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_dbms_sql_variable_value_varchar';

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  DESCRIBE_COLUMNS(c INTEGER, OUT col_cnt INTEGER, OUT DESC_T DBMS_SQL.DESC_TAB)       SPECIFIC DBMS_SQL_DESCRIBE_COLUMNS       BEGIN         DECLARE SQLCODE INTEGER;         DECLARE col_id INTEGER;         DECLARE col_type INTEGER;         DECLARE col_max_len INTEGER;         DECLARE col_name VARCHAR(128);         DECLARE col_name_len INTEGER;         DECLARE col_schema_name VARCHAR(128);         DECLARE col_schema_name_len INTEGER;         DECLARE col_precision INTEGER;         DECLARE col_scale INTEGER;         DECLARE col_charsetid INTEGER;         DECLARE col_charsetform INTEGER;         DECLARE col_null_ok INTEGER;         DECLARE stmt VARCHAR(200) DEFAULT 'SELECT * FROM SESSION.DBMS_SQL_DESCRIBE_INFO';         DECLARE CUR1 CURSOR FOR S1;                 /* Call IMP_DESCRIBE_COLUMNS to populate SESSION.DBMS_SQL_DESCRIBE_INFO */         CALL DBMS_SQL.IMP_DESCRIBE_COLUMNS( c, col_cnt );                 IF col_cnt > 0 THEN           PREPARE S1 FROM stmt;                     OPEN CUR1;                     fetchLoop: LOOP             FETCH CUR1 INTO col_id, col_type, col_max_len, col_name, col_precision, col_scale, col_null_ok;             IF SQLCODE = 100 THEN               LEAVE fetchLoop;             END IF;             SET desc_t[col_id].col_type = col_type;             SET desc_t[col_id].col_max_len = col_max_len;             SET desc_t[col_id].col_name = col_name;             SET desc_t[col_id].col_name_len = length(col_name);             SET desc_t[col_id].col_schema_name = NULL;             SET desc_t[col_id].col_schema_name_len = NULL;             SET desc_t[col_id].col_precision = col_precision;             SET desc_t[col_id].col_scale = col_scale;             SET desc_t[col_id].col_charsetid = NULL;             SET desc_t[col_id].col_charsetform = NULL;             SET desc_t[col_id].col_null_ok = col_null_ok;           END LOOP;                     CLOSE CUR1;         END IF;                 EXECUTE IMMEDIATE 'DROP TABLE SESSION.DBMS_SQL_DESCRIBE_INFO';       END;

ALTER MODULE "SYSIBMADM"."DBMS_SQL" PUBLISH
	PROCEDURE  DESCRIBE_COLUMNS2(c INTEGER, OUT col_cnt INTEGER, OUT DESC_TAB2 DBMS_SQL.DESC_TAB2)       SPECIFIC DBMS_SQL_DESCRIBE_COLUMNS2       BEGIN         DECLARE SQLCODE INTEGER;         DECLARE col_id INTEGER;         DECLARE col_type INTEGER;         DECLARE col_max_len INTEGER;         DECLARE col_name VARCHAR(32672);         DECLARE col_name_len INTEGER;         DECLARE col_schema_name VARCHAR(128);         DECLARE col_schema_name_len INTEGER;         DECLARE col_precision INTEGER;         DECLARE col_scale INTEGER;         DECLARE col_charsetid INTEGER;         DECLARE col_charsetform INTEGER;         DECLARE col_null_ok INTEGER;         DECLARE stmt VARCHAR(200) DEFAULT 'SELECT * FROM SESSION.DBMS_SQL_DESCRIBE_INFO';         DECLARE CUR1 CURSOR FOR S1;                 /* Call IMP_DESCRIBE_COLUMNS to populate SESSION.DBMS_SQL_DESCRIBE_INFO */         CALL DBMS_SQL.IMP_DESCRIBE_COLUMNS( c, col_cnt );                 IF col_cnt > 0 THEN           PREPARE S1 FROM stmt;                     OPEN CUR1;                     fetchLoop: LOOP             FETCH CUR1 INTO col_id, col_type, col_max_len, col_name, col_precision, col_scale, col_null_ok;             IF SQLCODE = 100 THEN               LEAVE fetchLoop;             END IF;             SET desc_tab2[col_id].col_type = col_type;             SET desc_tab2[col_id].col_max_len = col_max_len;             SET desc_tab2[col_id].col_name = col_name;             SET desc_tab2[col_id].col_name_len = length(col_name);             SET desc_tab2[col_id].col_schema_name = NULL;             SET desc_tab2[col_id].col_schema_name_len = NULL;             SET desc_tab2[col_id].col_precision = col_precision;             SET desc_tab2[col_id].col_scale = col_scale;             SET desc_tab2[col_id].col_charsetid = NULL;             SET desc_tab2[col_id].col_charsetform = NULL;             SET desc_tab2[col_id].col_null_ok = col_null_ok;           END LOOP;                     CLOSE CUR1;         END IF;                 EXECUTE IMMEDIATE 'DROP TABLE SESSION.DBMS_SQL_DESCRIBE_INFO';       END;

ALTER MODULE "SYSIBMADM"."DBMS_STANDARD" PUBLISH
	PROCEDURE  RAISE_APPLICATION_ERROR( num INTEGER, msg VARCHAR(2000), keeperrorstack BOOLEAN DEFAULT FALSE )       SPECIFIC DBMS_STANDARD_RAISE_APPLICATION_ERROR       LANGUAGE SQL       BEGIN         CALL SYSIBMADM.RAISE_APPLICATION_ERROR( num, msg, keeperrorstack );       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  appendToString(INOUT source VARCHAR(32672), IN string VARCHAR(32672))       SPECIFIC DBMS_UTILITY_APPENDTOSTRING       LANGUAGE SQL       BEGIN         IF(source IS NULL) THEN           SET source = string;         ELSEIF (string IS NOT NULL) THEN           SET source = source || string;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getAnalyzeOptions(IN method_opt VARCHAR(1024), INOUT allColumns CHAR(1), INOUT allIndexes CHAR(1),  INOUT allIndexedColumns CHAR(1), INOUT forTable CHAR(1), INOUT allLocalIndexes CHAR(1), INOUT cascade CHAR(1), OUT errorText VARCHAR(1024))       SPECIFIC DBMS_UTILITY_GETANALYZEOPTIONS       LANGUAGE SQL       BEGIN         DECLARE currentToken  VARCHAR(1024);         DECLARE previousToken VARCHAR(1024) DEFAULT ' ';         DECLARE tokenType     SMALLINT;         DECLARE delimiter     SMALLINT;         DECLARE nextPosition  INTEGER       DEFAULT 1;                 SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_EMPTY;         SET errorText = NULL;                 PARSEWHILELOOP:  WHILE (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END) DO                   CALL DBMS_UTILITY.getToken(method_opt, nextPosition, currentToken, tokenType, delimiter, FALSE);           /* ' '(space) and string-terminator are the only delimiters allowed here. */           IF ((delimiter != DBMS_UTILITY.DELIMITER_TYPE_SPACE) AND (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END)) THEN             SET errorText = 'SQL command not properly ended';             RETURN;           END IF;           /* If an empty token is found, its an error. It can happen if string contains spaces at the end. */           IF ((currentToken IS NULL) OR (LENGTH(TRIM(currentToken)) = 0)) THEN             LEAVE PARSEWHILELOOP;           END IF;                   SET currentToken = UPPER(currentToken);                     CASE previousToken             WHEN ' ' THEN               IF (currentToken = 'CASCADE') THEN                 CALL DBMS_UTILITY.handleOption(currentToken, cascade, errorText, TRUE);               ELSEIF (currentToken != 'FOR') THEN                 SET errorText = 'missing keyword';               END IF;                     WHEN 'FOR' THEN               IF (currentToken = 'TABLE') THEN                 CALL DBMS_UTILITY.handleOption(currentToken, forTable, errorText, TRUE);               ELSEIF (currentToken != 'ALL') THEN                   SET errorText = 'missing keyword';               END IF;                     WHEN 'ALL' THEN               IF (currentToken = 'COLUMNS') THEN                 /*'FOR ALL COLUMNS' AND 'FOR ALL INDEXED COLUMNS' are exclusive options so if any of these */                 /* two options are already true then it is an error case. We are checking for 'FOR ALL INDEXED COLUMNS' */                 /* here. Function call after this would check for 'FOR ALL COLUMNS'. */                 IF (allIndexedColumns = DBMS_UTILITY.OPTION_SET) THEN                   SET errorText = 'duplicate option';                 ELSE                   /* Do not reset the state machine as optional SIZE keyword can appear after FOR ALL COLUMNS */                   CALL DBMS_UTILITY.handleOption(currentToken, allColumns, errorText, FALSE);                 END IF;               ELSEIF (currentToken = 'INDEXES') THEN                 CALL DBMS_UTILITY.handleOption(currentToken, allIndexes, errorText, TRUE);               ELSEIF ((currentToken != 'INDEXED') AND (currentToken != 'LOCAL')) THEN                 SET errorText = 'missing keyword';               END IF;                     WHEN 'INDEXED' THEN               IF (currentToken = 'COLUMNS') THEN                 IF (allColumns = DBMS_UTILITY.OPTION_SET) THEN                    SET errorText = 'duplicate option';                 ELSE                   CALL DBMS_UTILITY.handleOption(currentToken, allIndexedColumns, errorText, FALSE);                 END IF;               ELSE                 SET errorText = 'missing keyword';               END IF;                     WHEN 'COLUMNS' THEN               /* As SIZE n is optional after 'FOR ALL COLUMNS' and 'FOR ALL INDEXED COLUMNS', so start of a new option */               /* string is also valid after this keyword. */               IF (currentToken = 'CASCADE') THEN                 CALL DBMS_UTILITY.handleOption(currentToken, cascade, errorText, FALSE);               ELSEIF ((currentToken != 'FOR') AND (currentToken != 'SIZE')) THEN                 SET errorText = 'missing keyword';               END IF;                     WHEN 'SIZE' THEN               /* Only integer value is allowed here */               IF (tokenType != DBMS_UTILITY.TOKEN_TYPE_INTEGER) THEN                 SET errorText = 'missing keyword';               END IF;               SET currentToken = ' ';                     WHEN 'LOCAL' THEN               IF (currentToken = 'INDEXES') THEN                 CALL DBMS_UTILITY.handleOption(currentToken, allLocalIndexes, errorText, TRUE);               END IF;             ELSE               SET errorText = 'missing keyword';           END CASE;                   IF (errorText IS NOT NULL) THEN             RETURN;           END IF;           SET previousToken = currentToken;         END WHILE;                 /* Check for incomplete option strings. */         IF ((previousToken != ' ') AND (previousToken != 'COLUMNS')) THEN           SET errorText = 'missing keyword';         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getFunctionDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETFUNCTIONDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepFunctions CURSOR FOR            SELECT TRIM(A.ROUTINESCHEMA), B.ROUTINENAME             FROM SYSCAT.ROUTINEDEP A , SYSCAT.ROUTINES B             WHERE BTYPE = baseType               AND BSCHEMA = schema               AND BNAME = (SELECT SPECIFICNAME FROM SYSCAT.ROUTINES WHERE                            ROUTINENAME = name AND ROUTINESCHEMA = schema)               AND A.SPECIFICNAME = B.SPECIFICNAME               AND A.ROUTINESCHEMA = B.ROUTINESCHEMA               AND B.ROUTINETYPE = 'F' ;                 DECLARE pkgCursorDepFunctions CURSOR FOR            SELECT R.ROUTINESCHEMA, R.ROUTINENAME             FROM SYSCAT.ROUTINEDEP RD , SYSCAT.MODULES M, SYSCAT.ROUTINES R             WHERE M.MODULESCHEMA = schema               AND M.MODULENAME = name               AND RD.BMODULEID = M.MODULEID               AND R.ROUTINESCHEMA = RD.ROUTINESCHEMA               AND R.ROUTINENAME = RD.ROUTINENAME               AND R.ROUTINEMODULENAME IS NULL               AND R.ROUTINETYPE = 'F'             UNION              SELECT ROUTINESCHEMA, ROUTINENAME FROM SYSCAT.ROUTINES WHERE ROUTINESCHEMA IS NULL AND ROUTINENAME IS NULL;                 IF (baseType = 'M') THEN           OPEN pkgCursorDepFunctions;           FETCH FROM pkgCursorDepFunctions INTO schemaName, objectName;                   WHILE(SQLSTATE = '00000') DO               CALL DBMS_OUTPUT.PUT_LINE('*   FUNCTION '|| TRIM(schemaName) || '.'  || TRIM(objectName) || '()');               FETCH FROM pkgCursorDepFunctions INTO schemaName, objectName;           END WHILE;                   CLOSE pkgCursorDepFunctions;                 ELSE           OPEN cursorDepFunctions;           FETCH FROM cursorDepFunctions INTO schemaName, objectName;                   WHILE(SQLSTATE = '00000') DO             CALL DBMS_OUTPUT.PUT_LINE('*   FUNCTION '|| schemaName || '.' || objectName || '()');             FETCH FROM cursorDepFunctions INTO schemaName, objectName;           END WHILE;                   CLOSE cursorDepFunctions;                 END IF;               END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getIndexDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETINDEXDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepIndex CURSOR FOR            SELECT INDSCHEMA, INDNAME              FROM SYSCAT.INDEXDEP              WHERE BTYPE = baseType               AND BSCHEMA = schema               AND BNAME = name;                 OPEN cursorDepIndex;         FETCH FROM cursorDepIndex INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   INDEX '|| schemaName || '.' || objectName || '()');           FETCH FROM cursorDepIndex INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepIndex;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getPackageDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETPACKAGEDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepPackage CURSOR FOR            WITH MODULEDEP AS            (             /*Dependent functions and procedures */             SELECT M.MODULESCHEMA AS MODULESCHEMA , M.MODULENAME AS MODULENAME, M.MODULEID AS MODULEID,                RD.BTYPE AS BTYPE, R.ROUTINESCHEMA AS BSCHEMA, R.ROUTINENAME AS BNAME             FROM                  SYSCAT.MODULES M, SYSCAT.ROUTINEDEP RD, SYSCAT.ROUTINES R               WHERE                  M.MODULEID = RD.ROUTINEMODULEID                 AND RD.BMODULENAME IS NULL                 AND RD.BNAME = R.SPECIFICNAME                 AND RD.BSCHEMA = R.ROUTINESCHEMA                 AND (RD.BTYPE = 'F' OR RD.BTYPE = 'R')             UNION             /*Dependent objects other than functions/procedures and packages used in package functions/procedures */             SELECT  M.MODULESCHEMA AS MODULESCHEMA , M.MODULENAME AS MODULENAME, M.MODULEID AS MODULEID,                RD.BTYPE AS BTYPE, RD.BSCHEMA AS BSCHEMA, RD.BNAME AS BNAME             FROM                  SYSCAT.MODULES M, SYSCAT.ROUTINEDEP RD              WHERE                  M.MODULEID = RD.ROUTINEMODULEID                 AND RD.BMODULENAME IS NULL                 AND (RD.BTYPE != 'K' AND RD.BTYPE != 'F' AND RD.BTYPE != 'R' )             UNION             /*Dependent variables */             SELECT M.MODULESCHEMA AS MODULESCHEMA , M.MODULENAME AS MODULENAME, M.MODULEID AS MODULEID,                VD.BTYPE AS BTYPE, VD.BSCHEMA AS BSCHEMA, VD.BNAME AS BNAME             FROM                  SYSCAT.MODULES M, SYSCAT.VARIABLEDEP VD              WHERE                  M.MODULEID = VD.VARMODULEID                 AND VD.BMODULENAME IS NULL                 AND VD.BTYPE != 'K'             UNION             /*Dependent types */             SELECT M.MODULESCHEMA AS MODULESCHEMA , M.MODULENAME AS MODULENAME, M.MODULEID AS MODULEID,                DD.BTYPE AS BTYPE, DD.BSCHEMA AS BSCHEMA, DD.BNAME AS BNAME             FROM                  SYSCAT.MODULES M, SYSCAT.DATATYPEDEP DD              WHERE                  M.MODULEID = DD.TYPEMODULEID                 AND DD.BMODULENAME IS NULL                 AND DD.BTYPE != 'K'             UNION             /*Now for dependent packages */             /*--Dependent package functions/procedures */             SELECT  M1.MODULESCHEMA AS MODULESCHEMA , M1.MODULENAME AS MODULENAME, M1.MODULEID AS MODULEID,                'M' AS BTYPE, M2.MODULESCHEMA AS BSCHEMA, M2.MODULENAME AS BNAME             FROM                  SYSCAT.MODULES M1,SYSCAT.MODULES M2, SYSCAT.ROUTINEDEP RD              WHERE                  M1.MODULEID = RD.ROUTINEMODULEID                 AND RD.BMODULENAME IS NOT NULL                 AND M2.MODULEID = RD.BMODULEID                           UNION             /*Dependent package variables */             SELECT  M1.MODULESCHEMA AS MODULESCHEMA , M1.MODULENAME AS MODULENAME, M1.MODULEID AS MODULEID,                'M' AS BTYPE, M2.MODULESCHEMA AS BSCHEMA, M2.MODULENAME AS BNAME             FROM                  SYSCAT.MODULES M1,SYSCAT.MODULES M2, SYSCAT.VARIABLEDEP VD             WHERE                  M1.MODULEID = VD.VARMODULEID                 AND VD.BMODULENAME IS NOT NULL                 AND M2.MODULEID = VD.BMODULEID             UNION             /*Dependent package types */             SELECT  M1.MODULESCHEMA AS MODULESCHEMA , M1.MODULENAME AS MODULENAME, M1.MODULEID AS MODULEID,                'M' AS BTYPE, M2.MODULESCHEMA AS BSCHEMA, M2.MODULENAME AS BNAME             FROM                  SYSCAT.MODULES M1,SYSCAT.MODULES M2, SYSCAT.DATATYPEDEP DD             WHERE                  M1.MODULEID = DD.TYPEMODULEID                 AND DD.BMODULENAME IS NOT NULL                 AND M2.MODULEID = DD.BMODULEID           )           SELECT MODULESCHEMA, MODULENAME              FROM MODULEDEP             WHERE BTYPE = baseType               AND BSCHEMA = schema               AND BNAME = name;                 OPEN cursorDepPackage;         FETCH FROM cursorDepPackage INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   PACKAGE '|| TRIM(schemaName) || '.'  || TRIM(objectName) || '()');           FETCH FROM cursorDepPackage INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepPackage;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getRoutineDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETROUTINEDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepRoutines CURSOR FOR            SELECT A.ROUTINESCHEMA, A.ROUTINENAME              FROM SYSCAT.ROUTINEDEP A , SYSCAT.ROUTINES B              WHERE BTYPE = baseType               AND BSCHEMA = schema               AND BNAME = name               AND A.ROUTINENAME = B.ROUTINENAME               AND A.ROUTINESCHEMA = B.ROUTINESCHEMA               AND B.ROUTINETYPE = 'P';                 DECLARE pkgCursorDepRoutines CURSOR FOR            SELECT R.ROUTINESCHEMA, R.ROUTINENAME             FROM SYSCAT.ROUTINEDEP RD , SYSCAT.MODULES M, SYSCAT.ROUTINES R             WHERE M.MODULESCHEMA = schema               AND M.MODULENAME = name               AND RD.BMODULEID = M.MODULEID               AND R.ROUTINESCHEMA = RD.ROUTINESCHEMA               AND R.ROUTINENAME = RD.ROUTINENAME               AND R.ROUTINEMODULENAME IS NULL               AND R.ROUTINETYPE = 'P'             UNION              SELECT ROUTINESCHEMA, ROUTINENAME FROM SYSCAT.ROUTINES WHERE ROUTINESCHEMA IS NULL AND ROUTINENAME IS NULL;                 IF (baseType = 'M') THEN           OPEN pkgCursorDepRoutines;           FETCH FROM pkgCursorDepRoutines INTO schemaName, objectName;                   WHILE(SQLSTATE = '00000') DO             CALL DBMS_OUTPUT.PUT_LINE('*   PROCEDURE '|| TRIM(schemaName) || '.'  || TRIM(objectName) || '()');             FETCH FROM pkgCursorDepRoutines INTO schemaName, objectName;           END WHILE;                   CLOSE pkgCursorDepRoutines;                 ELSE           OPEN cursorDepRoutines;           FETCH FROM cursorDepRoutines INTO schemaName, objectName;           WHILE(SQLSTATE = '00000') DO             CALL DBMS_OUTPUT.PUT_LINE('*   PROCEDURE '|| schemaName || '.'  || objectName || '()');             FETCH FROM cursorDepRoutines INTO schemaName, objectName;           END WHILE;         CLOSE cursorDepRoutines;         END IF;                END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getSampleClause(IN sample_clause VARCHAR(128), OUT rowsCount VARCHAR(50), OUT analyzeType VARCHAR(10))       SPECIFIC DBMS_UTILITY_GETSAMPLECLAUSE       LANGUAGE SQL       BEGIN         DECLARE currentToken  VARCHAR(128);         DECLARE previousToken VARCHAR(128)  DEFAULT ' ';         DECLARE nextPosition  INTEGER       DEFAULT 1;         DECLARE tokenType     SMALLINT;         DECLARE delimiter     SMALLINT;                 SET rowsCount   = NULL;         SET analyzeType = NULL;         SET delimiter   = DBMS_UTILITY.DELIMITER_TYPE_EMPTY;         /* Parse the sample_clause */         PARSEWHILELOOP:  WHILE ((delimiter != DBMS_UTILITY.DELIMITER_TYPE_INVALID) OR                                  (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END)) DO           /* Tokenize sample_clause string */           CALL DBMS_UTILITY.getToken(sample_clause, nextPosition, currentToken, tokenType, delimiter, FALSE);           IF ((currentToken IS NULL) OR (LENGTH(TRIM(currentToken)) = 0)) THEN             LEAVE PARSEWHILELOOP;           END IF;                     SET currentToken = UPPER(currentToken);                     CASE             WHEN (previousToken = ' ') THEN               IF  currentToken != 'SAMPLE' THEN                 CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE' );               END IF;                     WHEN (previousToken = 'SAMPLE') THEN               IF (tokenType != DBMS_UTILITY.TOKEN_TYPE_INTEGER) THEN                 CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE' );               ELSE                 SET rowsCount = currentToken;                 SET currentToken = 'INTVAL';               END IF;                     WHEN (previousToken = 'INTVAL') THEN               IF (currentToken = 'PERCENT') THEN                 SET analyzeType = 'PERCENT';               ELSEIF (currentToken = 'ROWS') THEN                 SET analyzeType = 'ROWS';               ELSE                 CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE' );               END IF;                     ELSE                 CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE' );           END CASE;           SET previousToken = currentToken;         END WHILE;                 /* If we are unable to get percent-of-rows or number-of-rows (for estimating the statistics) */         /* throw an error. */         IF ((rowsCount IS NULL) OR (analyzeType IS NULL)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE' );         END IF;               END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getTableDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETTABLEDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                  DECLARE cursorDepTables CURSOR FOR            SELECT TABSCHEMA, TABNAME             FROM SYSCAT.TABDEP             WHERE BTYPE = baseType               AND DTYPE = DBMS_UTILITY.OPTION_SET               AND BNAME = name               AND BSCHEMA = schema;                 OPEN cursorDepTables;         FETCH FROM cursorDepTables INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   TABLE '|| schemaName || '.' || objectName || '()');           FETCH FROM cursorDepTables INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepTables;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getToken(IN source VARCHAR(32672), INOUT pos INTEGER, OUT token VARCHAR(32672), OUT tokenType SMALLINT, OUT delimiter SMALLINT,IN eatSpaces BOOLEAN)       SPECIFIC DBMS_UTILITY_GETTOKEN       LANGUAGE SQL       BEGIN         DECLARE state       SMALLINT;         DECLARE len         INTEGER;         DECLARE currentChar CHAR(1);         DECLARE endQuoteLoc INTEGER;                 SET state     = DBMS_UTILITY.STATE_START;         SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID;         SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_END;                 SET len   = LENGTH(source) + 1;         SET token = NULL;                 PARSE_WHILE_LOOP: WHILE (pos < len) DO           /* We would now pick each character from source-string one by one and process it. */           SET currentChar = SUBSTR(source, pos, 1);           SET pos = pos + 1;                   CASE             /* If a QUOTE is found, all characters until ending-QUOTE would be picked without processing. */             WHEN (currentChar = '"') THEN               /* If QUOTE is found while a state is already started, then its an error. Like in string: abc"hello". */               /* In this string "abc" is a valid identfier, but QUOTE is encountered before the identifier completion */               /* (with a delimiter). So, we would given an error here. */               IF (state != DBMS_UTILITY.STATE_START) THEN                  SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;                  SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID_MISSING_PERIOD;                  RETURN;               END IF;                       /* We have found starting-QUOTE, find corresponding ending-QUOTE. And if ending-QUOTE is not found, */               /* return with an error. */               SET endQuoteLoc = LOCATE('"', source, pos);                       IF (endQuoteLoc = 0) THEN                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID_MISSING_DOUBLE_QUOTE;                 SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;                 RETURN;               ELSE                 /* Extract the string starting from start-of-QUOTE upto end-of-QUOTE. */                 SET token = SUBSTR(source, pos, endQuoteLoc - pos);                 SET pos = endQuoteLoc + 1;                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_QUOTED;                 SET state = DBMS_UTILITY.STATE_QUOTE_END;               END IF;                     /* If ".", "," or "@" characters are found, simply end-up the token processing. */             WHEN (currentChar = '.') THEN               SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_DOT;               LEAVE PARSE_WHILE_LOOP;                     WHEN (currentChar = ',') THEN               SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_COMMA;               LEAVE PARSE_WHILE_LOOP;                     WHEN (currentChar = '@') THEN               SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT;               LEAVE PARSE_WHILE_LOOP;                     WHEN (currentChar = ' ') THEN               IF (eatSpaces = FALSE) THEN                 /* 'Space' at start of token won't be considered as delimiter, so ignore if its start-of-token. */                 IF (state != DBMS_UTILITY.STATE_START) THEN                   SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_SPACE;                   LEAVE PARSE_WHILE_LOOP;                 END IF;               ELSE                 CALL DBMS_UTILITY.appendToString(token,currentChar);                 IF (state != DBMS_UTILITY.STATE_START) THEN                   SET state = DBMS_UTILITY.STATE_SPACE_AT_END;                 END IF;               END IF;                     WHEN (((currentChar >= 'A') AND (currentChar <= 'Z'))                   OR ((currentChar >= 'a') AND (currentChar <= 'z'))                   OR (currentChar = '_')) THEN               IF (state = DBMS_UTILITY.STATE_START) THEN                 SET state = DBMS_UTILITY.STATE_STRING_START;                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_STRING;               ELSEIF (state != DBMS_UTILITY.STATE_STRING_START) THEN                 SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID_MISSING_PERIOD;                 RETURN;               END IF;               CALL DBMS_UTILITY.appendToString(token,currentChar);                     WHEN (currentChar >= '0' AND currentChar <= '9') THEN                IF (state = DBMS_UTILITY.STATE_START) THEN                 SET state = DBMS_UTILITY.STATE_INT_START;                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INTEGER;               ELSEIF ((state = DBMS_UTILITY.STATE_QUOTE_END) OR                      (state = DBMS_UTILITY.STATE_SPACE_AT_END)) THEN                 SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;                 SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID;                 RETURN;               END IF;               CALL DBMS_UTILITY.appendToString(token,currentChar);                     ELSE               /* An illegal character found here. So, mark an invalid delimiter and exit from function. */               /* (All characters except handled above are illegal characters) */               SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;               SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID_CHARACTER;               RETURN;           END CASE;         END WHILE;                 IF (LENGTH(token) > DBMS_UTILITY.MAX_IDENTIFIER_LENGTH) THEN           SET delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID;           SET tokenType = DBMS_UTILITY.TOKEN_TYPE_INVALID_IDENTIFIER_TOO_LONG;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getTriggerDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETTRIGGERDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepTriggers CURSOR FOR           SELECT TRIGSCHEMA, TRIGNAME             FROM SYSCAT.TRIGDEP             WHERE BTYPE=baseType               AND BSCHEMA= schema               AND BNAME= name;                 OPEN cursorDepTriggers;         FETCH FROM cursorDepTriggers INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   TRIGGER '|| schemaName || '.' || objectName || '()');           FETCH FROM cursorDepTriggers INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepTriggers;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getVariableDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETVARIABLEDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepVariables CURSOR FOR            SELECT VARSCHEMA, VARNAME             FROM SYSCAT.VARIABLEDEP             WHERE BTYPE = baseType               AND BNAME = name               AND BSCHEMA = schema;                 OPEN cursorDepVariables;         FETCH FROM cursorDepVariables INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   VARIABLE '|| schemaName || '.' || objectName || '()');           FETCH FROM cursorDepVariables INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepVariables;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  getViewDependency(IN schema VARCHAR(128), IN name VARCHAR(128), baseType CHAR(1))       SPECIFIC DBMS_UTILITY_GETVIEWDEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName VARCHAR(128);         DECLARE objectName VARCHAR(128);         DECLARE SQLSTATE   CHAR(5)      DEFAULT '00000';                 DECLARE cursorDepViews CURSOR FOR           SELECT VIEWSCHEMA, VIEWNAME             FROM SYSCAT.VIEWDEP             WHERE BTYPE = baseType               AND DTYPE = 'V'               AND BNAME = name               AND BSCHEMA = schema;                 OPEN cursorDepViews;         FETCH FROM cursorDepViews INTO schemaName, objectName;                 WHILE(SQLSTATE = '00000') DO           CALL DBMS_OUTPUT.PUT_LINE('*   VIEW '|| schemaName || '.' || objectName || '()');           FETCH FROM cursorDepViews INTO schemaName, objectName;         END WHILE;                 CLOSE cursorDepViews;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  handleOption(INOUT currentToken VARCHAR(1024), INOUT option CHAR(1), OUT errorText VARCHAR(1024), IN resetState BOOLEAN)       SPECIFIC DBMS_UTILITY_HANDLEOPTION       LANGUAGE SQL       BEGIN         IF (option = DBMS_UTILITY.OPTION_SET) THEN           /* If option is already Set throw duplication-option error */           SET errorText = 'duplicate option';         ELSEIF (option = DBMS_UTILITY.OPTION_DISABLED) THEN           /* This option has encountered but it was instructed (using input parameters) to be disabled. */           /* So, give an error here. */           SET errorText = 'missing keyword';         ELSE           SET option = DBMS_UTILITY.OPTION_SET;          END IF;                 /* If state machine requires Reset, reset it to  ' '(space) */         IF (resetState = TRUE) THEN           SET currentToken = ' ';         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  nameResolveFP(IN name VARCHAR(1024), IN a VARCHAR(128), IN b VARCHAR(128), IN c VARCHAR(128), OUT schema_name VARCHAR(128), OUT part1 VARCHAR(128), OUT part2 VARCHAR(128), OUT part1_type INTEGER, OUT object_number INTEGER)       SPECIFIC DBMS_UTILITY_NAMERESOLVEFP       LANGUAGE SQL       BEGIN         DECLARE type       CHAR(1);         /* Declare Exit-handler for case when no data found in SELECT INTO. Which means we are not able to resolve given name. */         DECLARE EXIT HANDLER FOR SQLSTATE VALUE '02000'         BEGIN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, name);         END;         /* Look for function/procedure or package name, Both functions and procedures resides in SYSCAT.ROUTINES view */         /* and ROUTINETYPE Column differentiates between a function, procedure and method. */         /* NOTE: We consider methods as procedures. */         /* Case when name contains 3 parts(a.b.c):  */         /* For this case we have only one possibility that name specified is a SCHEMA.PACKAGE.PROCEDURE/FUNCTION */         IF ((c IS NOT NULL) AND (LENGTH(TRIM(c)) != 0)) THEN           SELECT R.ROUTINESCHEMA, R.ROUTINEMODULENAME, R.ROUTINENAME, M.MODULEID, 'Z'              INTO schema_name, part1, part2, object_number, type             FROM SYSCAT.ROUTINES R, SYSCAT.MODULES M               WHERE (R.ROUTINEMODULENAME = M.MODULENAME AND R.ROUTINESCHEMA = M.MODULESCHEMA)                AND (R.ROUTINESCHEMA = a AND R.ROUTINEMODULENAME = b AND R.ROUTINENAME = c)              FETCH FIRST 1 ROWS ONLY;                 ELSEIF ((b IS NOT NULL) AND (LENGTH(TRIM(b)) != 0)) THEN           /*Case when name contains 2 parts(a.b):  */           /*In this case we have three possibilities. */           /*1) name specified is a SCHEMA.PACKAGE */           /*2) name specified is a PACKAGE.PROCEDURE/FUNCTION */           /*3) name specified is a SCHEMA.PROCEDURE/FUNCTION */           /*Case1: Try resolving the name into SCHEMA.PACKAGE */           IF EXISTS (SELECT * FROM SYSCAT.MODULES WHERE MODULESCHEMA = a AND MODULENAME = b) THEN              SELECT MODULESCHEMA, MODULENAME, MODULEID, 'Z'                INTO schema_name, part1, object_number, type               FROM SYSCAT.MODULES                WHERE MODULESCHEMA = a AND MODULENAME = b                FETCH FIRST 1 ROWS ONLY;           /*Case2: Try resolving the name into PACKAGE.PROCEDURE/FUNCTION */           ELSEIF EXISTS (SELECT * FROM SYSCAT.ROUTINES WHERE ROUTINEMODULENAME = a AND ROUTINENAME = b) THEN              SELECT R.ROUTINESCHEMA, R.ROUTINEMODULENAME, R.ROUTINENAME, M.MODULEID, 'Z'                INTO schema_name, part1, part2, object_number, type               FROM SYSCAT.ROUTINES R, SYSCAT.MODULES M                 WHERE (R.ROUTINEMODULENAME = M.MODULENAME AND R.ROUTINESCHEMA = M.MODULESCHEMA)                 AND (R.ROUTINEMODULENAME = a AND R.ROUTINENAME = b)                FETCH FIRST 1 ROWS ONLY;           /*Case3: Try resolving the name into SCHEMA.PROCEDURE/FUNCTION */           ELSE             SELECT ROUTINESCHEMA, ROUTINENAME, ROUTINEID, ROUTINETYPE                INTO schema_name, part1, object_number, type               FROM SYSCAT.ROUTINES                WHERE ROUTINEMODULENAME IS NULL AND ROUTINESCHEMA = a AND ROUTINENAME = b               FETCH FIRST 1 ROWS ONLY;           END IF;         ELSE           /*Case when name contains only one part: */           /*This name could be either package name or function/procedure name.  */           IF EXISTS (SELECT * FROM SYSCAT.MODULES WHERE MODULENAME = a) THEN             SELECT MODULESCHEMA, MODULENAME, MODULEID, 'Z'                INTO schema_name, part2, object_number, type               FROM SYSCAT.MODULES WHERE MODULENAME = a                FETCH FIRST 1 ROWS ONLY;           ELSE             /*The name was not a package name, Try to look for non package function/procedure with this name */             SELECT ROUTINESCHEMA, ROUTINENAME, ROUTINEID, ROUTINETYPE                INTO schema_name, part2, object_number, type               FROM SYSCAT.ROUTINES                WHERE ROUTINENAME = a AND ROUTINEMODULENAME IS NULL                FETCH FIRST 1 ROWS ONLY;           END IF;         END IF;                 IF (type = 'Z') THEN           SET part1_type = 9;         ELSEIF (type = 'F') THEN           SET part1_type = 8;         ELSE           SET part1_type = 7;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  nameResolveT(IN name VARCHAR(1024), IN a VARCHAR(128), IN b VARCHAR(128), IN c VARCHAR(128), OUT schema_name VARCHAR(128), OUT part1 VARCHAR(128), OUT part2 VARCHAR(128), OUT part1_type INTEGER, OUT object_number INTEGER)       SPECIFIC DBMS_UTILITY_NAMERESOLVET       LANGUAGE SQL       BEGIN         DECLARE type        CHAR(1);         /* Declare Exit handler for case when no data found in SELECT INTO. Which means we are not able to resolve given name. */         DECLARE EXIT HANDLER FOR SQLSTATE VALUE '02000'         BEGIN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, name);         END;         /* Look for trigger which resides in SYSCAT.TRIGGERS View */         IF ((c IS NOT NULL) AND (LENGTH(TRIM(c)) > 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_RESOLVE', 'NAME');         ELSEIF ((b IS NOT NULL) AND (LENGTH(TRIM(b)) > 0)) THEN           SELECT TRIGSCHEMA, TRIGNAME INTO schema_name, part1              FROM SYSCAT.TRIGGERS WHERE TRIGSCHEMA = a AND TRIGNAME = b FETCH FIRST 1 ROWS ONLY;         ELSE           SELECT TRIGSCHEMA, TRIGNAME INTO schema_name, part1              FROM SYSCAT.TRIGGERS WHERE TRIGNAME = a FETCH FIRST 1 ROWS ONLY;         END IF;         SET part1_type = 12;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" ADD
	PROCEDURE  nameResolveTVSS(IN name VARCHAR(1024), IN a VARCHAR(128), IN b VARCHAR(128), IN c VARCHAR(128), OUT schema_name VARCHAR(128), OUT part1 VARCHAR(128), OUT part2 VARCHAR(128), OUT part1_type INTEGER, OUT object_number INTEGER)       SPECIFIC DBMS_UTILITY_NAMERESOLVETVSS       LANGUAGE SQL       BEGIN         DECLARE type        CHAR(1);         DECLARE baseSchema  VARCHAR(128);         DECLARE baseName    VARCHAR(128);                 /* Declare Exit handler for case when no data found in SELECT INTO. which means we are not able to resolve given name */         DECLARE EXIT HANDLER FOR SQLSTATE VALUE '02000'         BEGIN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, name);         END;         /* Look for table, synonym, view or sequence name, Tables, Views and Synonym resides in SYSCAT.TABLES View */         /* and TYPE Columns tells that it is of type Table, View or Synonym. */         IF ((b IS NOT NULL) AND (LENGTH(TRIM(b)) > 0)) THEN           IF (EXISTS (SELECT * FROM SYSCAT.TABLES WHERE TABSCHEMA = a AND TABNAME = b)) THEN              /* First try resolving this into table, view or synonym */             SELECT TABSCHEMA, TABNAME, TABLEID ,TYPE INTO schema_name, part1, object_number, type                FROM SYSCAT.TABLES WHERE TABSCHEMA = a AND TABNAME = b FETCH FIRST 1 ROWS ONLY;           ELSEIF (EXISTS (SELECT * FROM SYSCAT.SEQUENCES WHERE SEQSCHEMA = a AND SEQNAME = b)) THEN              /* Try resolving sequence */             SELECT SEQSCHEMA, SEQNAME, SEQID INTO schema_name, part1, object_number                FROM SYSCAT.SEQUENCES WHERE SEQSCHEMA = a AND SEQNAME = b FETCH FIRST 1 ROWS ONLY;           ELSE             /* Try resolving this name by ignoring part-B */             IF (EXISTS (SELECT * FROM SYSCAT.TABLES WHERE TABNAME = a)) THEN                SELECT TABSCHEMA, TABNAME, TABLEID, TYPE INTO schema_name, part1, object_number, type                  FROM SYSCAT.TABLES WHERE TABNAME = a FETCH FIRST 1 ROWS ONLY;             ELSE               SELECT SEQSCHEMA, SEQNAME, SEQID INTO schema_name, part1, object_number                  FROM SYSCAT.SEQUENCES WHERE SEQSCHEMA = a FETCH FIRST 1 ROWS ONLY;                   END IF;           END IF;         ELSE           /* Only part-A is given in "name" (i.e. no dotted notation) */           IF (EXISTS (SELECT * FROM SYSCAT.TABLES WHERE TABNAME = a)) THEN              SELECT TABSCHEMA, TABNAME, TABLEID, TYPE INTO schema_name, part1, object_number, type               FROM SYSCAT.TABLES WHERE TABNAME = a FETCH FIRST 1 ROWS ONLY;           ELSE             SELECT SEQSCHEMA, SEQNAME, SEQID INTO schema_name, part1, object_number                FROM SYSCAT.SEQUENCES WHERE SEQNAME = a FETCH FIRST 1 ROWS ONLY;           END IF;         END IF;                 /* Check if resolved table was a synonym, if yes then resolve this into base object. */         /* WHILE loop is used if synonym points to another synonym, hence we keep on searching */         /* for the real object. */         WHILE (type =  'A') DO           SELECT BASE_TABSCHEMA, BASE_TABNAME INTO baseSchema, baseName             FROM SYSCAT.TABLES WHERE TABSCHEMA = schema_name AND TABNAME = part1 FETCH FIRST 1 ROWS ONLY;           SELECT TABSCHEMA, TABNAME, TABLEID ,TYPE INTO schema_name, part1, object_number, type              FROM SYSCAT.TABLES WHERE TABSCHEMA = baseSchema AND TABNAME = baseName FETCH FIRST 1 ROWS ONLY;         END WHILE;                 IF (type =  'Q') THEN     /*Sequence */           SET part1_type = 6;         ELSEIF (type =  'V') THEN /* View */           SET part1_type = 4;         ELSE                       /*Table */           SET part1_type = 2;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	FUNCTION  "GET_CPU_TIME"()
	RETURNS BIGINT
	LANGUAGE C
	SPECIFIC DBMS_UTILITY_GET_CPU_TIME
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	FUNCTION  "GET_HASH_VALUE"(NAME VARCHAR(32672),
		BASE INTEGER,
		HASH_SIZE INTEGER)
	RETURNS BIGINT
	LANGUAGE C
	SPECIFIC DBMS_UTILITY_GET_HASH_VALUE
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	FUNCTION  "GET_TIME"()
	RETURNS BIGINT
	LANGUAGE C
	SPECIFIC DBMS_UTILITY_GET_TIME
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  ANALYZE_DATABASE(IN method VARCHAR(128), IN estimate_rows INTEGER DEFAULT NULL, IN estimate_percent INTEGER DEFAULT NULL, IN method_opt VARCHAR(1024) DEFAULT NULL)       SPECIFIC DBMS_UTILITY_ANALYZE_DATABASE       LANGUAGE SQL       BEGIN         DECLARE schemaName        VARCHAR(128);         DECLARE tableName         VARCHAR(128);         DECLARE runstatsOptions   VARCHAR(1024) DEFAULT ' ';         DECLARE numericLiteral    VARCHAR(10);         DECLARE cmdString         VARCHAR(1024);                 DECLARE allColumns        CHAR(1);         DECLARE forTable          CHAR(1);         DECLARE allIndexes        CHAR(1);         DECLARE allIndexedColumns CHAR(1);         DECLARE allLocalIndexes   CHAR(1);         DECLARE optionCascade     CHAR(1);         DECLARE errorText         VARCHAR(1024)  DEFAULT NULL;         DECLARE SQLSTATE          CHAR(5)        DEFAULT '00000';                 DECLARE cursorAllTables CURSOR FOR SELECT TABSCHEMA,TABNAME FROM SYSCAT.TABLES WHERE TYPE = 'T';                 SET allColumns        = DBMS_UTILITY.OPTION_ENABLED;    /* Enabled option FOR ALL COLUMNS */         SET forTable          = DBMS_UTILITY.OPTION_ENABLED;    /* Enabled option FOR TABLE */         SET allIndexes        = DBMS_UTILITY.OPTION_ENABLED;    /* Enabled option FOR ALL INDEXES */         SET allIndexedColumns = DBMS_UTILITY.OPTION_ENABLED;    /* Enabled option FOR ALL INDEXED COLUMNS */         SET allLocalIndexes   = DBMS_UTILITY.OPTION_DISABLED;   /* Disabled option FOR ALL LOCAL INDEXES */         SET optionCascade     = DBMS_UTILITY.OPTION_DISABLED;   /* Disabled option CASCADE   */                 CALL DBMS_UTILITY.getAnalyzeOptions(                           method_opt,                   /* method option string to parse */                           allColumns,                   /* option FOR ALL COLUMNS (Enabled in this case) */                           allIndexes,                   /* option FOR ALL INDEXES (Enabled in this case) */                           allIndexedColumns,            /* option FOR ALL INDEXED COLUMNS (Disabled in this case) */                           forTable,                     /* option FOR TABLE (Enabled in this case) */                           allLocalIndexes,              /* option FOR ALL LOCAL INDEXES (Disabled in this case) */                           optionCascade,                /* option FOR CASCADE (Disabled in this case) */                           errorText);                   /* string to hold error text in case of an error */                 IF (errorText IS NOT NULL) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '4', 'DBMS_UTILITY.ANALYZE_DATABASE', 'METHOD_OPT');         END IF;                 IF (method IS NULL) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.ANALYZE_DATABASE', 'METHOD');         END IF;                 SET method = UPPER(TRIM(method));         /* For COMPUTE method we would set numericLiteral to 100. Because using 100 percent rows for */         /* ESTIMATE-ing statistics will be equivalent to COMPUTE-ing the statistics. */         IF (method = 'DELETE') THEN           /*DELETE method is no-op so return without doing anything. */           RETURN;         ELSEIF (method = 'COMPUTE') THEN           SET numericLiteral = '100';         ELSEIF (method = 'ESTIMATE') THEN           IF (estimate_percent IS NULL) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '3', 'DBMS_UTILITY.ANALYZE_DATABASE', 'ESTIMATE_PERCENT');           ELSEIF (estimate_percent < 0 OR  estimate_percent > 100) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '3', 'DBMS_UTILITY.ANALYZE_DATABASE', 'ESTIMATE_PERCENT');           END IF;           SET numericLiteral = CHAR(estimate_percent);         ELSE            CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.ANALYZE_DATABASE', 'METHOD');         END IF;                 IF (allColumns = DBMS_UTILITY.OPTION_SET) THEN           SET runstatsOptions = runstatsOptions || 'ON ALL COLUMNS ';         END IF;                 IF (allIndexedColumns = DBMS_UTILITY.OPTION_SET) THEN           SET runstatsOptions = runstatsOptions || 'ON KEY COLUMNS ';         END IF;                 IF (allIndexes = DBMS_UTILITY.OPTION_SET) THEN           IF (runstatsOptions = ' ') THEN             SET runstatsOptions = runstatsOptions || 'FOR INDEXES ALL ';           ELSE             SET runstatsOptions = runstatsOptions || 'AND INDEXES ALL ';           END IF;         END IF;                 SET runstatsOptions = runstatsOptions || 'TABLESAMPLE BERNOULLI (' || numericLiteral || ') ';                 /* Pick up each table of this database from SYSCAT.TABLES catalog and execute RUNSTATS */         /* command on it. */         OPEN cursorAllTables;         FETCH FROM cursorAllTables INTO schemaName, tableName;         CURSORLOOP: WHILE (SQLSTATE = '00000') DO                   SET cmdString = 'RUNSTATS ON TABLE "' || schemaName || '"."' || tableName || '"';           SET cmdString = cmdString || runstatsOptions;           CALL SYSPROC.ADMIN_CMD(cmdString);                   FETCH FROM cursorAllTables INTO schemaName, tableName;         END WHILE;         CLOSE cursorAllTables;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  ANALYZE_PART_OBJECT(IN schema VARCHAR(128), IN object_name VARCHAR(128), IN object_type CHAR(1) DEFAULT 'T', IN command_type CHAR(1) DEFAULT 'E', IN command_opt VARCHAR(1024) DEFAULT NULL, IN sample_clause VARCHAR(128) DEFAULT 'SAMPLE 5 PERCENT')       SPECIFIC DBMS_UTILITY_ANALYZE_PART_OBJECT       LANGUAGE SQL       BEGIN         DECLARE tableSchema     VARCHAR(128);         DECLARE tableName       VARCHAR(128);         DECLARE indexSchema     VARCHAR(128);         DECLARE indexName       VARCHAR(128);         DECLARE numericLiteral  VARCHAR(50)    DEFAULT '5';         DECLARE cmdString       VARCHAR(1024);         DECLARE allColumns         CHAR(1);         DECLARE forTable           CHAR(1);         DECLARE allLocalIndexes    CHAR(1);         DECLARE optionCascade      CHAR(1);         DECLARE allIndexes         CHAR(1);         DECLARE allIndexedColumns  CHAR(1);         DECLARE totalRows          INTEGER;           DECLARE sampleRows         INTEGER;                 DECLARE errorText       VARCHAR(1024)  DEFAULT NULL;         DECLARE analyzeType     VARCHAR(10);                 DECLARE CSR2            CURSOR FOR FLSQL;                 /* Declare exit handler for the case if index does not exist. */         DECLARE EXIT HANDLER FOR SQLSTATE VALUE '02000'           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '2', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'OBJECT_NAME');                 IF ((schema IS NULL) OR (LENGTH(TRIM(schema)) = 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SCHEMA');         END IF;                 IF ((object_name IS NULL) OR (LENGTH(TRIM(object_name)) = 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '2', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'OBJECT_NAME');         END IF;                 IF ((object_type IS NULL) OR (SYSIBM.LOCATE(object_type,'TI') = 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '3', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'OBJECT_TYPE');         END IF;                 IF ((command_type IS NULL) OR (SYSIBM.LOCATE(command_type, 'ECV') = 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '4', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'COMMAND_TYPE');         END IF;                 /* There is no direct way of executing RUNSTATS command for indexes. So we firstly need */         /* table name of this index. Then we would pass this table name along with index name to  */         /* RUNSTATS command. */         IF (object_type = 'I') THEN           SELECT TBCREATOR, TBNAME             INTO tableSchema, tableName             FROM SYSIBM.SYSINDEXES             WHERE NAME = object_name AND CREATOR = schema;                   SET tableSchema = RTRIM(tableSchema); /* Remove trailing spaces */           SET indexSchema = schema;           SET indexName = object_name;         ELSEIF (object_type = 'T') THEN           SET tableSchema = schema;           SET tableName = object_name;         END IF;                 IF (command_type = 'E') THEN           CALL DBMS_UTILITY.getSampleClause(sample_clause, numericLiteral, analyzeType);           SET sampleRows = numericLiteral;                   IF(sampleRows < 0) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '6', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE');           END IF;                   IF(analyzeType = 'ROWS') THEN             /*There is no way of specifing number of rows for estimating statistics in RUNSTATS command. */             /*So if SAMPLE BY ROWS is specified as analyze type we need to convert the number of rows into percent of rows for RUNSTATS command */             /*Get total number of rows in the table */             SET cmdString = 'SELECT COUNT(*)  FROM ' || tableSchema || '.' ||tableName;             PREPARE FLSQL FROM cmdString;             OPEN CSR2;             FETCH CSR2 INTO totalRows;             CLOSE CSR2;                     /*If Rows in table are less then or equal to sample rows then use 100 % rows for statistics */             IF(sampleRows >= totalRows) THEN               SET numericLiteral = '100';             /*If sampleRows = 0 then no need to calculate percentage. Just pass 0 to RUNSTATS command */             ELSEIF(sampleRows > 0) THEN               /*Calculate the percent of rows */               SET sampleRows = sampleRows * 100;               SET sampleRows = (sampleRows / totalRows) + 1;               SET numericLiteral = sampleRows;             END IF;                   ELSEIF(analyzeType = 'PERCENT') THEN             IF(sampleRows > 100) THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '6', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE');             END IF;              ELSE             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '6', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'SAMPLE_CLAUSE');           END IF;         ELSEIF (command_type = 'C') THEN           /* For command_type 'C' (COMPUTE) we would set numericLiteral to 100. Because using 100 percent rows for */           /* ESTIMATE-ing statistics will be equivalent to COMPUTE-ing the statistics. */           SET numericLiteral = '100';         END IF;                 /* We would use 'REORG TABLE' command for validating partitioned table. */         IF (command_type = 'V') THEN           /* Get command options for command type 'V', The only valid command options for command type 'V'  */           /* is [ CASCADE ]. So, we will disable all other options while parsing command option in this  */           /* case except 'CASCADE' */           /* Note: */           /*   REORG command has no way to handle CASCADE option. We are parsing this option just for */           /*   syntax validity. It would simply be ignored after parsing. */           SET allColumns        = DBMS_UTILITY.OPTION_DISABLED;  /* Disabled option FOR ALL COLUMNS */           SET forTable          = DBMS_UTILITY.OPTION_DISABLED;  /* Disabled option FOR TABLE */           SET allIndexes        = DBMS_UTILITY.OPTION_DISABLED;  /* Disabled option FOR ALL INDEXES */           SET allIndexedColumns = DBMS_UTILITY.OPTION_DISABLED;  /* Disabled option FOR ALL INDEXED COLUMNS   */           SET allLocalIndexes   = DBMS_UTILITY.OPTION_DISABLED;  /* Disabled option FOR ALL LOCAL INDEXES */           SET optionCascade     = DBMS_UTILITY.OPTION_ENABLED;   /* Enabled option FOR ALL LOCAL INDEXES */           SET errorText     = NULL;           CALL DBMS_UTILITY.getAnalyzeOptions(                                               command_opt,                   /* method option string to parse */                                               allColumns,                   /* option FOR ALL COLUMNS (Disabled in this case) */                                               allIndexes,                   /* option FOR ALL INDEXES (Disabled in this case) */                                               allIndexedColumns,            /* option FOR ALL INDEXED COLUMNS (Disabled in this case) */                                               forTable,                     /* option FOR TABLE (Disabled in this case) */                                               allLocalIndexes,              /* option FOR ALL LOCAL INDEXES (Disabled in this case) */                                               optionCascade,                /* option FOR CASCADE (Enabled in this case) */                                               errorText);                   /* string to hold error text in case of error */                   IF (errorText IS NOT NULL) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'COMMAND_OPT');           END IF;                   SET cmdString = 'REORG TABLE ' || tableSchema || '.' || tableName;                   IF (object_type = 'I') THEN              SET cmdString = cmdString || ' INDEX ' || indexSchema || '.' || indexName;           END IF;                   SET cmdString = cmdString || ' ON ALL DBPARTITIONNUMS ';         ELSE           /* Get command options for command type E and C. The valid command options for command type  */           /* 'E' and 'C' are as following: */           /* [ FOR TABLE ] */           /* [ FOR ALL COLUMNS ] */           /* [ FOR ALL LOCAL INDEXES ] */           /* So we will disable all other options while parsing command option in this case except above. */           SET allColumns        = DBMS_UTILITY.OPTION_ENABLED;           SET forTable          = DBMS_UTILITY.OPTION_ENABLED;           SET allIndexes        = DBMS_UTILITY.OPTION_DISABLED;           SET allIndexedColumns = DBMS_UTILITY.OPTION_DISABLED;           SET allLocalIndexes   = DBMS_UTILITY.OPTION_ENABLED;           SET optionCascade     = DBMS_UTILITY.OPTION_DISABLED;           SET errorText     = NULL;           CALL DBMS_UTILITY.getAnalyzeOptions(command_opt,                                               allColumns,                                               allIndexes,                                               allIndexedColumns,                                               forTable,                                               allLocalIndexes,                                               optionCascade,                                               errorText);                   IF (errorText IS NOT NULL) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'COMMAND_OPT');           END IF;                   SET cmdString = 'RUNSTATS ON TABLE "' || tableSchema || '"."' || tableName || '"';           /* For object type I all command options will be ignored */           IF (object_type = 'I') THEN              SET cmdString = cmdString ||' FOR INDEXES ' || indexSchema || '.' || indexName;           ELSEIF (object_type = 'T') THEN              IF (allColumns = DBMS_UTILITY.OPTION_SET) THEN               SET cmdString = cmdString || ' WITH DISTRIBUTION ON ALL COLUMNS ';             ELSE               SET cmdString = cmdString || ' WITH DISTRIBUTION DEFAULT ';             END IF;             IF (allLocalIndexes = DBMS_UTILITY.OPTION_SET) THEN               SET cmdString = cmdString || ' AND INDEXES ALL ';             END IF;           END IF;           SET cmdString = cmdString || ' TABLESAMPLE BERNOULLI (' || numericLiteral || ') ';         END IF;         /* Execute the command using ADMIN_CMD procedure */         CALL SYSPROC.ADMIN_CMD(cmdString);       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  ANALYZE_SCHEMA(IN schema VARCHAR(128), IN method VARCHAR(128), IN estimate_rows INTEGER DEFAULT NULL, IN estimate_percent INTEGER DEFAULT NULL, IN method_opt VARCHAR(1024) DEFAULT NULL)       SPECIFIC DBMS_UTILITY_ANALYZE_SCHEMA       LANGUAGE SQL       BEGIN         DECLARE schemaName        VARCHAR(128);         DECLARE tableName         VARCHAR(128);         DECLARE runstatsOptions   VARCHAR(1024) DEFAULT ' ';         DECLARE numericLiteral    VARCHAR(10);         DECLARE cmdString         VARCHAR(1024);                 DECLARE allColumns        CHAR(1);         DECLARE forTable          CHAR(1);         DECLARE allIndexes        CHAR(1);         DECLARE allIndexedColumns CHAR(1);         DECLARE allLocalIndexes   CHAR(1);         DECLARE optionCascade     CHAR(1);                 DECLARE errorText         VARCHAR(1024) DEFAULT NULL;         DECLARE SQLSTATE          CHAR(5)       DEFAULT '00000';                 DECLARE cursorAllTables CURSOR FOR SELECT TABSCHEMA,TABNAME FROM SYSCAT.TABLES WHERE TYPE = 'T' AND TABSCHEMA = UPPER(schema);                 IF ((schema IS NULL) OR (LENGTH(TRIM(schema)) = 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'SCHEMA');         END IF;                 /*Check if schema exists */         IF NOT EXISTS (SELECT * FROM SYSCAT.SCHEMATA WHERE SCHEMANAME = UPPER(schema)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, schema);         END IF;                 SET allColumns        = DBMS_UTILITY.OPTION_ENABLED;  /* Enabled option FOR ALL COLUMNS */         SET forTable          = DBMS_UTILITY.OPTION_ENABLED;  /* Enabled option FOR TABLE */         SET allIndexes        = DBMS_UTILITY.OPTION_ENABLED;  /* Enabled option FOR ALL INDEXES */         SET allIndexedColumns = DBMS_UTILITY.OPTION_ENABLED;  /* Enabled option FOR ALL INDEXED COLUMNS */         SET allLocalIndexes   = DBMS_UTILITY.OPTION_DISABLED; /* Disabled option FOR ALL LOCAL INDEXES */         SET optionCascade     = DBMS_UTILITY.OPTION_DISABLED; /* Disabled option CASCADE   */                 CALL DBMS_UTILITY.getAnalyzeOptions(                               method_opt,                   /* method option string to parse */                               allColumns,                   /* option FOR ALL COLUMNS (Enabled in this case) */                               allIndexes,                   /* option FOR ALL INDEXES (Enabled in this case) */                               allIndexedColumns,            /* option FOR ALL INDEXED COLUMNS (Disabled in this case) */                               forTable,                     /* option FOR TABLE (Enabled in this case) */                               allLocalIndexes,              /* option FOR ALL LOCAL INDEXES (Disabled in this case) */                               optionCascade,                /* option FOR CASCADE (Disabled in this case) */                               errorText);                   /* string to hold error text in case of error */                 IF (errorText IS NOT NULL) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '5', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'METHOD_OPT');         END IF;                 IF (method IS NULL) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '2', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'METHOD');         END IF;                 SET method = UPPER(TRIM(method));         /* For COMPUTE method we would set numericLiteral to 100. Because using 100 percent rows for */         /* ESTIMATE-ing statistics will be equivalent to COMPUTE-ing the statistics. */         IF (method = 'DELETE') THEN           /*DELETE method is no-op so return without doing anything. */           RETURN;         ELSEIF (method = 'COMPUTE') THEN           SET numericLiteral = '100';                 ELSEIF (method = 'ESTIMATE') THEN           IF (estimate_percent IS NULL) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '4', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'ESTIMATE_PERCENT');           ELSEIF (estimate_percent < 0 OR  estimate_percent > 100) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '4', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'ESTIMATE_PERCENT');           END IF;           SET numericLiteral = CHAR(estimate_percent);                 ELSE           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '2', 'DBMS_UTILITY.ANALYZE_SCHEMA', 'METHOD');         END IF;                 IF (allColumns = DBMS_UTILITY.OPTION_SET) THEN           SET runstatsOptions = runstatsOptions || 'ON ALL COLUMNS ';         END IF;                 IF (allIndexedColumns = DBMS_UTILITY.OPTION_SET) THEN           SET runstatsOptions = runstatsOptions || 'ON KEY COLUMNS ';         END IF;                 IF (allIndexes = DBMS_UTILITY.OPTION_SET) THEN           IF (runstatsOptions = ' ') THEN             SET runstatsOptions = runstatsOptions || 'FOR INDEXES ALL ';           ELSE             SET runstatsOptions = runstatsOptions || 'AND INDEXES ALL ';           END IF;         END IF;                 SET runstatsOptions = runstatsOptions || 'TABLESAMPLE BERNOULLI (' || numericLiteral || ') ';                 /* Pick up each table of this schema one by one and execute RUNSTATS command on it. */         OPEN cursorAllTables;         FETCH FROM cursorAllTables INTO schemaName, tableName;         CURSORLOOP: WHILE (SQLSTATE = '00000') DO                   SET cmdString = 'RUNSTATS ON TABLE "' || schemaName || '"."' || tableName || '"';           SET cmdString = cmdString || runstatsOptions;                   CALL SYSPROC.ADMIN_CMD(cmdString);                   FETCH FROM cursorAllTables INTO schemaName, tableName;         END WHILE;         CLOSE cursorAllTables;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  CANONICALIZE(IN name VARCHAR(1024), OUT canon_name VARCHAR(1024), IN canon_len INTEGER)       SPECIFIC DBMS_UTILITY_CANONICALIZE       LANGUAGE SQL       BEGIN         DECLARE len               INTEGER;         DECLARE nextPosition      INTEGER       DEFAULT 1;         DECLARE token             VARCHAR(1024);         DECLARE tempCanon         VARCHAR(1024) DEFAULT NULL;         DECLARE tokenType         SMALLINT;         DECLARE delimiter         SMALLINT;         DECLARE previousDelimiter SMALLINT;         DECLARE periodFound       BOOLEAN;                 IF((canon_len IS NULL) OR (canon_len < 0)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '3', 'DBMS_UTILITY.NAME_CANONICALIZE', 'CANON_LEN');         END IF;         /*If the name = NULL, name = ''(empty string) or canon_len parameter is 0, then the canonical name should be null. */         IF ((name IS NULL) OR (canon_len = 0)) THEN           SET canon_name = NULL;           RETURN;         END IF;         /*If name contain only blanks then the canonicalized name should be the same blank characters */         IF (LENGTH(TRIM(name)) = 0) THEN           IF(canon_len < LENGTH(name)) THEN             SET canon_name = SUBSTR(name, 1, canon_len);           ELSE             SET canon_name = name;           END IF;           RETURN;         END IF;                 SET periodFound = FALSE;         SET previousDelimiter = DBMS_UTILITY.DELIMITER_TYPE_EMPTY;         LOOP1:  REPEAT           CALL DBMS_UTILITY.getToken(name, nextPosition, token, tokenType, delimiter, FALSE);                   IF ((token IS NULL) OR (LENGTH(TRIM(token)) = 0)) THEN             IF (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END) THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');             ELSE               LEAVE LOOP1;             END IF;           END IF;                   IF ((previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_DOT) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_EMPTY)) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');           END IF;                   IF ((delimiter = DBMS_UTILITY.DELIMITER_TYPE_COMMA) OR               (delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT)) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');           END IF;                   IF (tokenType = DBMS_UTILITY.TOKEN_TYPE_STRING) THEN             SET token = UPPER(token);             /* Check if the token is valid identifier by ensuring that it does not starts with 'SYS'. */             IF (SUBSTR(token, 1, 3) = 'SYS') THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');             END IF;                   ELSEIF (tokenType != DBMS_UTILITY.TOKEN_TYPE_QUOTED) THEN             /* Token found is neither double-quoted nor simple-string type. And we allow nothing other than */             /* these two. */             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');           END IF;                           IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_DOT) THEN             /* As string contains the periods so double-quote the token and append it to result string */             CALL DBMS_UTILITY.appendToString(tempCanon,'"' || token || '".');             SET periodFound = TRUE;           ELSE                     IF(periodFound = TRUE) THEN              CALL DBMS_UTILITY.appendToString(tempCanon,'"' || token || '"');             ELSE               CALL DBMS_UTILITY.appendToString(tempCanon, token);             END IF;           END IF;                   SET previousDelimiter = delimiter;         UNTIL (delimiter = DBMS_UTILITY.DELIMITER_TYPE_END)         END REPEAT;                  /* input name can only end with space or valid identifier */         IF((previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_END) AND           (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_SPACE) AND           (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_EMPTY)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_CANONICALIZE', 'NAME');         END IF;         /* Truncate the resultant canonicalized string and assign it to out parameter. */         IF(canon_len < LENGTH(tempCanon)) THEN           SET canon_name = SUBSTR(tempCanon, 1, canon_len);         ELSE           SET canon_name = tempCanon;         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  COMMA_TO_TABLE_LNAME(IN list VARCHAR(32672), OUT tablen INTEGER, OUT tab DBMS_UTILITY.LNAME_ARRAY)       SPECIFIC DBMS_UTILITY_COMMA_TO_TABLE_LNAME       LANGUAGE SQL       BEGIN         DECLARE len               INTEGER;         DECLARE nextPosition      INTEGER       DEFAULT 1;         DECLARE token             VARCHAR(256);         DECLARE outToken          VARCHAR(4000) DEFAULT NULL;         DECLARE tokenType         SMALLINT;         DECLARE delimiter         SMALLINT;         DECLARE previousDelimiter SMALLINT;                 SET tablen = 0;                 LOOP1:  REPEAT           CALL DBMS_UTILITY.getToken(list , nextPosition, token, tokenType, delimiter, TRUE);                   IF ((token IS NULL) OR (LENGTH(TRIM(token)) = 0)) THEN             IF (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END) THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_LNAME', 'LIST');             ELSE               LEAVE LOOP1;             END IF;           END IF;                   IF ( delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID OR 	     ( tokenType = DBMS_UTILITY.TOKEN_TYPE_INTEGER ) OR 	     ( (tokenType = DBMS_UTILITY.TOKEN_TYPE_STRING) AND 	       (SUBSTR(token,1,1) = '_') ) ) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_LNAME', 'LIST');           END IF;                   IF ((previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_DOT) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_COMMA) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_EMPTY) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_AT)) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_LNAME', 'LIST');           END IF;                   /* Now append the token to result string */           CALL DBMS_UTILITY.appendToString(outToken,token);                   IF ((delimiter = DBMS_UTILITY.DELIMITER_TYPE_COMMA) OR               (delimiter = DBMS_UTILITY.DELIMITER_TYPE_END)) THEN             SET tablen = tablen + 1;             SET tab[tablen] = outToken;             SET outToken = NULL;           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_DOT) THEN             CALL DBMS_UTILITY.appendToString(outToken,'.');           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_LNAME', 'LIST');           END IF;                   SET previousDelimiter = delimiter;         UNTIL (delimiter = DBMS_UTILITY.DELIMITER_TYPE_END)         END REPEAT;                 IF (tablen = 0) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_LNAME', 'LIST');         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  COMMA_TO_TABLE_UNCL(IN list VARCHAR(32672), OUT tablen INTEGER, OUT tab DBMS_UTILITY.UNCL_ARRAY)       SPECIFIC DBMS_UTILITY_COMMA_TO_TABLE_UNCL       LANGUAGE SQL       BEGIN         DECLARE len               INTEGER;         DECLARE nextPosition      INTEGER       DEFAULT 1;         DECLARE token             VARCHAR(256);         DECLARE outToken          VARCHAR(228)  DEFAULT NULL;         DECLARE errorText         VARCHAR(1024);         DECLARE tokenType         SMALLINT;         DECLARE delimiter         SMALLINT;         DECLARE previousDelimiter SMALLINT;                 SET tablen = 0;                 LOOP1:  REPEAT           CALL DBMS_UTILITY.getToken(list , nextPosition, token, tokenType, delimiter, TRUE);                   IF ((token IS NULL) OR (LENGTH(TRIM(token)) = 0)) THEN             IF (delimiter != DBMS_UTILITY.DELIMITER_TYPE_END) THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_UNCL', 'LIST');             ELSE               LEAVE LOOP1;             END IF;           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID  OR 	     ( tokenType = DBMS_UTILITY.TOKEN_TYPE_INTEGER ) OR 	     ( (tokenType = DBMS_UTILITY.TOKEN_TYPE_STRING) AND 	       (SUBSTR(token,1,1) = '_') ) ) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_UNCL', 'LIST');           END IF;                   IF ((previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_DOT) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_COMMA) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_EMPTY) AND              (previousDelimiter != DBMS_UTILITY.DELIMITER_TYPE_AT)) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_UNCL', 'LIST');           END IF;                   /* Now append the token to result string */           CALL DBMS_UTILITY.appendToString(outToken,token);                   IF ((delimiter = DBMS_UTILITY.DELIMITER_TYPE_COMMA) OR               (delimiter = DBMS_UTILITY.DELIMITER_TYPE_END)) THEN             SET tablen = tablen + 1;             SET tab[tablen] = outToken;             SET outToken = NULL;           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_DOT) THEN             CALL DBMS_UTILITY.appendToString(outToken,'.');           END IF;                   IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_UNCL', 'LIST');           END IF;                   SET previousDelimiter = delimiter;         UNTIL (delimiter = DBMS_UTILITY.DELIMITER_TYPE_END)         END REPEAT;                 IF (tablen = 0) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.COMMA_TO_TABLE_UNCL', 'LIST');         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  COMPILE_SCHEMA(schema VARCHAR(128), compile_all BOOLEAN DEFAULT FALSE, reuse_settings BOOLEAN DEFAULT FALSE)       SPECIFIC DBMS_UTILITY_COMPILE_SCHEMA       LANGUAGE SQL       BEGIN         IF (compile_all IS NULL OR compile_all <> FALSE ) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'DBMS_UTILITY.COMPILE_SCHEMA', 'COMPILE_ALL' );         ELSEIF (reuse_settings IS NULL OR reuse_settings <> FALSE ) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '3', 'DBMS_UTILITY.REUSE_SETTINGS', 'REUSE_SETTINGS' );         END IF;                 CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS(NULL, schema, NULL);       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  DB_VERSION(OUT version VARCHAR(1024), OUT compatibility VARCHAR(1024))       SPECIFIC DBMS_UTILITY_DB_VERSION       LANGUAGE SQL       BEGIN         /* SELECT SERVICE_LEVEL, SERVICE_LEVEL INTO version, compatibility FROM SYSIBMADM.ENV_INST_INFO; */         DECLARE stmt VARCHAR(200) DEFAULT            'SELECT SERVICE_LEVEL, SERVICE_LEVEL FROM SYSIBMADM.ENV_INST_INFO';         DECLARE C1 CURSOR FOR S1;                 PREPARE S1 FROM stmt;         OPEN C1;         FETCH C1 INTO version, compatibility;         CLOSE C1;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  EXEC_DDL_STATEMENT(parse_string VARCHAR(1024))       SPECIFIC DBMS_UTILITY_EXEC_DDL_STATEMENT       LANGUAGE SQL       BEGIN         EXECUTE IMMEDIATE(parse_string);       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  GET_DEPENDENCY(IN type VARCHAR(128), IN schema VARCHAR(128), IN name VARCHAR(128))       SPECIFIC DBMS_UTILITY_GET_DEPENDENCY       LANGUAGE SQL       BEGIN         DECLARE schemaName   VARCHAR(128);         DECLARE objectName   VARCHAR(128);         DECLARE baseType     CHAR(1);         DECLARE errorText    VARCHAR(1024) DEFAULT NULL;         DECLARE outputText   VARCHAR(1024) ;         DECLARE canonType    VARCHAR(20);         DECLARE isBodyExists INTEGER DEFAULT 0;                 SET schemaName = UPPER(schema);         SET objectName = UPPER(name);                 IF (type IS NULL) THEN           SET type = '  ';         END IF;                 IF (schema IS NOT NULL) THEN           SET errorText = schema || '.';         END IF;         IF (name IS NOT NULL) THEN           CALL DBMS_UTILITY.appendToString(errorText,name);         END IF;                 SET canonType = UPPER(TRIM(TYPE));                 CASE canonType           WHEN 'TABLE' THEN             IF EXISTS (SELECT * FROM SYSCAT.TABLES WHERE TYPE = 'T' AND TABSCHEMA = schemaName AND TABNAME = objectName) THEN                SET baseType = 'T';               SET outputText = '*TABLE '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'VIEW' THEN             IF EXISTS (SELECT * FROM SYSCAT.VIEWS WHERE VIEWSCHEMA = schemaName AND VIEWNAME = objectName) THEN                SET baseType = 'V';               SET outputText = '*VIEW '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'INDEX' THEN             IF EXISTS (SELECT * FROM SYSCAT.INDEXES WHERE INDSCHEMA = schemaName AND INDNAME = objectName) THEN                SET baseType = 'I';               SET outputText = '*INDEX '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'FUNCTION' THEN             IF EXISTS (SELECT * FROM SYSCAT.ROUTINES WHERE ROUTINETYPE = 'F' AND ROUTINESCHEMA = schemaName AND ROUTINENAME = objectName) THEN                SET baseType = 'F';               SET outputText = '*FUNCTION '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'PACKAGE' THEN             IF EXISTS (SELECT * FROM SYSCAT.MODULES WHERE MODULESCHEMA = schemaName AND MODULENAME = objectName) THEN                SET baseType = 'M';               SET outputText = '*PACKAGE '|| schemaName || '.'  || objectName || '()';               /*Check if package contains package body */               SELECT (CASE WHEN REMARKS = 'PL/SQL Package Body' then 1 else 0 end) as abc into isBodyExists                 FROM SYSCAT.MODULES WHERE MODULESCHEMA = schemaName AND MODULENAME = objectName;             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'PROCEDURE' THEN             IF EXISTS (SELECT * FROM SYSCAT.ROUTINES WHERE ROUTINETYPE = 'P' AND ROUTINESCHEMA = schemaName AND ROUTINENAME = objectName) THEN               SET baseType = 'F';               SET outputText = '*PROCEDURE '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'TRIGGER' THEN             IF EXISTS (SELECT * FROM SYSCAT.TRIGGERS WHERE TRIGSCHEMA = schemaName AND TRIGNAME = objectName) THEN               SET baseType = 'B';               SET outputText = '*TRIGGER '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;                   WHEN 'SEQUENCE' THEN             IF EXISTS (SELECT * FROM SYSCAT.SEQUENCES WHERE SEQSCHEMA = schemaName AND SEQNAME = objectName) THEN                SET baseType = 'Q';               SET outputText = '*SEQUENCE '|| schemaName || '.'  || objectName || '()';             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, errorText);             END IF;           ELSE             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.GET_DEPENDENCY', 'TYPE');         END CASE;                 CALL DBMS_OUTPUT.PUT_LINE('DEPENDENCIES ON '|| schemaName ||'.' || objectName);         CALL DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------------');         CALL DBMS_OUTPUT.PUT_LINE(outputText);                 IF (isBodyExists = 1) THEN           CALL DBMS_OUTPUT.PUT_LINE('*   PACKAGE BODY '|| schemaName || '.'  || objectName || '()');         END IF;                 /* Get dependencies on each object */         CALL DBMS_UTILITY.getTableDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getViewDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getVariableDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getTriggerDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getRoutineDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getFunctionDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getIndexDependency(schemaName, objectName, baseType);         CALL DBMS_UTILITY.getPackageDependency(schemaName, objectName, baseType);       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  NAME_RESOLVE(IN name VARCHAR(1024), IN context INTEGER, OUT schema_name VARCHAR(128),OUT part1 VARCHAR(128), OUT part2 VARCHAR(128), OUT dblink VARCHAR(128), OUT part1_type INTEGER, OUT object_number INTEGER)       SPECIFIC DBMS_UTILITY_NAME_RESOLVE       LANGUAGE SQL       BEGIN         DECLARE a            VARCHAR(128);         DECLARE b            VARCHAR(128);         DECLARE c            VARCHAR(128);         DECLARE dbLinkPart   VARCHAR(128);         DECLARE nextPosition INTEGER;                 IF ((context IS NULL) OR (context < 1) OR (context > 3)) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '2', 'DBMS_UTILITY.ANALYZE_PART_OBJECT', 'CONTEXT');         END IF;                 SET part1_type = 0;         /* Use DBMS_UTILITY.NAME_TOKENIZE to seperate the parts of an object */         CALL DBMS_UTILITY.NAME_TOKENIZE(name, a,  b, c, dbLinkPart, nextPosition);          /* If name contains the dblink then no need to look in catalog tables.  */         IF ((dbLinkPart IS NOT NULL) AND (LENGTH(TRIM(dbLinkPart)) != 0)) THEN           SET schema_name = a;           SET part1       = b;           SET part2       = c;           SET dblink      = dbLinkPart;           RETURN;         END IF;                 IF (context = 1) THEN           CALL DBMS_UTILITY.nameResolveFP(name, a, b, c, schema_name, part1, part2, part1_type, object_number);         ELSEIF (context = 2) THEN           CALL DBMS_UTILITY.nameResolveTVSS(name, a, b, c, schema_name, part1, part2, part1_type, object_number);         ELSEIF (context = 3) THEN           CALL DBMS_UTILITY.nameResolveT(name, a, b, c, schema_name, part1, part2, part1_type, object_number);         ELSE           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-204, name);         END IF;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  NAME_TOKENIZE(IN name VARCHAR(1024), OUT a VARCHAR(128), OUT b VARCHAR(128), OUT c VARCHAR(128), OUT dblink VARCHAR(32672), OUT nextPosition INTEGER)       SPECIFIC DBMS_UTILITY_NAME_TOKENIZE       LANGUAGE SQL       BEGIN         DECLARE len               INTEGER;         DECLARE part              CHAR(1)         DEFAULT 'A';         DECLARE token             VARCHAR(1024);         DECLARE tokenType         SMALLINT;         DECLARE delimiter         SMALLINT;         DECLARE previousDelimiter SMALLINT;                 SET delimiter           = DBMS_UTILITY.DELIMITER_TYPE_EMPTY;         SET previousDelimiter         = DBMS_UTILITY.DELIMITER_TYPE_EMPTY;         SET dblink          = NULL;         SET nextPosition        = 1;                 IF (name IS NULL) THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');         END IF;                 /* First of all tokenize the given string. Keep on watching the delimter of each token, and keep on  */         /* building "parts" (part-A, part-B, part-C) until the token are being endup with '.'. And build final- */         /* part (i.e. dblink) if previous part ended-up with delimiter '@'. */         LOOP1:  REPEAT           CALL DBMS_UTILITY.getToken(name, nextPosition, token, tokenType, delimiter, FALSE);                    IF(delimiter = DBMS_UTILITY.DELIMITER_TYPE_INVALID) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');           END IF;                   IF (tokenType = DBMS_UTILITY.TOKEN_TYPE_STRING) THEN             SET token = UPPER(token);           END IF;                   IF ((token IS NULL) OR (LENGTH(TRIM(token)) = 0)) THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');           END IF;                   CASE previousDelimiter             WHEN DBMS_UTILITY.DELIMITER_TYPE_EMPTY THEN               IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT) THEN                 SET a = token;                 SET part = 'D';               ELSE                 SET a = token;                 SET part = 'B';               END IF;                     WHEN  DBMS_UTILITY.DELIMITER_TYPE_DOT THEN               IF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_DOT) THEN                 IF (part = 'B') THEN                   SET b = token;                   SET part = 'C';                 ELSEIF (part = 'D') THEN                   CALL DBMS_UTILITY.appendToString(dblink, '.' ||  token);                 ELSE                   CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');                 END IF;               ELSEIF (delimiter = DBMS_UTILITY.DELIMITER_TYPE_AT) THEN                 IF (part = 'B') THEN                    SET b = token;                 ELSEIF (part = 'C') THEN                   SET c = token;                 ELSEIF (part = 'D') THEN                    CALL DBMS_UTILITY.appendToString(dblink, '@' ||  token);                 ELSE                    CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');                 END IF;                 SET part = 'D';               ELSE                 IF (part = 'B') THEN                    SET b = token;                 ELSEIF (part = 'C') THEN                   SET c = token;                 ELSEIF (part = 'D') THEN                    CALL DBMS_UTILITY.appendToString(dblink, '.' ||  token);                 ELSE                   CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');                 END IF;               END IF;                     WHEN DBMS_UTILITY.DELIMITER_TYPE_AT THEN               IF (dblink IS NULL) THEN                 SET dblink = token;               ELSE                 SET dblink = dblink || '@' ||  token;                END IF;           END CASE;           SET previousDelimiter = delimiter;         UNTIL ((delimiter != DBMS_UTILITY.DELIMITER_TYPE_DOT) AND (delimiter != DBMS_UTILITY.DELIMITER_TYPE_AT))         END REPEAT;                 IF (part = 'A') THEN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR(-171, '1', 'DBMS_UTILITY.NAME_TOKENIZE', 'NAME');         END IF;         SET nextPosition = nextPosition - 1;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  TABLE_TO_COMMA_LNAME(IN tab DBMS_UTILITY.LNAME_ARRAY, OUT tablen INTEGER, OUT list VARCHAR(32672))       SPECIFIC DBMS_UTILITY_TABLE_TO_COMMA_LNAME       LANGUAGE SQL       BEGIN         DECLARE pos       INTEGER;                 SET list = NULL;         SET pos  = 1;                 WHILE_LOOP: WHILE (pos <= CARDINALITY(tab)) DO                   IF (( tab[pos] IS NULL ) OR ( LENGTH(TRIM(tab[pos])) = 0 )) THEN             LEAVE WHILE_LOOP;           END IF;                   IF (list is NULL) THEN             SET list = tab[pos];           ELSE             SET list = list || ',' || tab[pos];           END IF;                   SET pos       = pos + 1;                 END WHILE;                 SET tablen = pos - 1;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  TABLE_TO_COMMA_UNCL(IN tab DBMS_UTILITY.UNCL_ARRAY, OUT tablen INTEGER, OUT list VARCHAR(32672))       SPECIFIC DBMS_UTILITY_TABLE_TO_COMMA_UNCL       LANGUAGE SQL       BEGIN         DECLARE pos       INTEGER;                 SET list = NULL;         SET pos  = 1;                 WHILE_LOOP: WHILE (pos <= CARDINALITY(tab)) DO                   IF ((tab[pos] IS NULL) OR (LENGTH(tab[pos]) = 0)) THEN             LEAVE WHILE_LOOP;           END IF;                   IF (list is NULL) THEN             SET list = tab[pos];           ELSE             SET list = list || ',' || tab[pos];           END IF;                   SET pos       = pos + 1;                 END WHILE;                 SET tablen = pos - 1;       END;

ALTER MODULE "SYSIBMADM"."DBMS_UTILITY" PUBLISH
	PROCEDURE  VALIDATE(IN object_id INTEGER)       SPECIFIC DBMS_UTILITY_VALIDATE       LANGUAGE SQL       BEGIN         DECLARE schemaName  VARCHAR(128);         DECLARE routineName VARCHAR(128);         DECLARE EXIT HANDLER FOR SQLSTATE VALUE '02000'           RETURN;                 SELECT ROUTINESCHEMA, ROUTINENAME INTO schemaName, routineName FROM SYSCAT.ROUTINES WHERE ROUTINEID = object_id;         CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS(NULL, schemaName, routinename);       END;

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	PROCEDURE  COMMONREQMETRICS ( INOUT REPOUTPUT REPORT_TYPE, INOUT IR INTEGER, IN MSGCACHE REPORT_TYPE, IN TIMEINTERVAL INTEGER, IN WLM_QUEUE_TIME_TOTAL BIGINT, IN AGENT_WAIT_TIME BIGINT, IN TCPIP_RECVS_TOTAL BIGINT, IN TCPIP_SENDS_TOTAL BIGINT, IN IPC_RECVS_TOTAL BIGINT, IN IPC_SENDS_TOTAL BIGINT, IN TCPIP_SEND_WAIT_TIME BIGINT, IN TCPIP_RECV_WAIT_TIME BIGINT, IN IPC_SEND_WAIT_TIME BIGINT, IN IPC_RECV_WAIT_TIME BIGINT, IN TCPIP_RECV_VOLUME BIGINT, IN IPC_RECV_VOLUME BIGINT, IN TCPIP_SEND_VOLUME BIGINT, IN IPC_SEND_VOLUME BIGINT, IN LOCK_ESCALS BIGINT, IN LOCK_WAITS BIGINT, IN LOCK_TIMEOUTS BIGINT, IN DEADLOCKS BIGINT, IN ACT_COMPLETED_TOTAL BIGINT, IN ACT_ABORTED_TOTAL BIGINT, IN ACT_REJECTED_TOTAL BIGINT, IN APP_RQSTS_COMPLETED_TOTAL BIGINT, IN TOTAL_RQST_TIME BIGINT, IN TOTAL_CPU_TIME BIGINT, IN TOTAL_WAIT_TIME BIGINT, IN TOTAL_ACT_TIME BIGINT, IN TOTAL_ACT_WAIT_TIME BIGINT, IN ROWS_READ BIGINT, IN ROWS_RETURNED BIGINT, IN ROWS_MODIFIED BIGINT, IN POOL_DATA_L_READS BIGINT, IN POOL_INDEX_L_READS BIGINT, IN POOL_TEMP_DATA_L_READS BIGINT, IN POOL_TEMP_INDEX_L_READS BIGINT, IN POOL_TEMP_XDA_L_READS BIGINT, IN POOL_XDA_L_READS BIGINT, IN POOL_DATA_P_READS BIGINT, IN POOL_INDEX_P_READS BIGINT, IN POOL_TEMP_DATA_P_READS BIGINT, IN POOL_TEMP_INDEX_P_READS BIGINT, IN POOL_TEMP_XDA_P_READS BIGINT, IN POOL_XDA_P_READS BIGINT, IN POOL_READ_TIME BIGINT, IN POOL_WRITE_TIME BIGINT, IN POOL_DATA_WRITES BIGINT, IN POOL_INDEX_WRITES BIGINT, IN POOL_XDA_WRITES BIGINT, IN DIRECT_READ_TIME BIGINT, IN DIRECT_READS BIGINT, IN DIRECT_READ_REQS BIGINT, IN DIRECT_WRITE_TIME BIGINT, IN DIRECT_WRITES BIGINT, IN DIRECT_WRITE_REQS BIGINT, IN LOG_DISK_WAIT_TIME BIGINT, IN LOG_DISK_WAITS_TOTAL BIGINT, IN NUM_LOG_BUFFER_FULL BIGINT, IN CLIENT_IDLE_WAIT_TIME BIGINT, IN LOCK_WAIT_TIME BIGINT, IN FCM_SEND_WAIT_TIME BIGINT, IN TOTAL_SORTS BIGINT, IN SORT_OVERFLOWS BIGINT, IN POST_THRESHOLD_SORTS BIGINT, IN POST_SHRTHRESHOLD_SORTS BIGINT, IN FCM_SEND_VOLUME BIGINT, IN FCM_SENDS_TOTAL BIGINT, IN FCM_RECV_VOLUME BIGINT, IN FCM_RECVS_TOTAL BIGINT, IN WLM_QUEUE_ASSIGNMENTS_TOTAL BIGINT, IN FCM_RECV_WAIT_TIME BIGINT, IN TOTAL_SECTION_PROC_TIME BIGINT, IN TOTAL_SECTION_SORT_PROC_TIME BIGINT, IN TOTAL_COMPILE_PROC_TIME BIGINT, IN TOTAL_IMPLICIT_COMPILE_PROC_TIME BIGINT, IN TOTAL_COMMIT_PROC_TIME BIGINT, IN TOTAL_ROLLBACK_PROC_TIME BIGINT, IN TOTAL_RUNSTATS_PROC_TIME BIGINT, IN TOTAL_REORG_PROC_TIME BIGINT, IN TOTAL_LOAD_PROC_TIME BIGINT, IN TOTAL_APP_COMMITS BIGINT, IN TOTAL_ROUTINE_INVOCATIONS BIGINT, IN TOTAL_ROUTINE_TIME BIGINT, IN TOTAL_COMPILATIONS BIGINT, IN PKG_CACHE_INSERTS BIGINT, IN PKG_CACHE_LOOKUPS BIGINT, IN CAT_CACHE_INSERTS BIGINT, IN CAT_CACHE_LOOKUPS BIGINT, IN INT_COMMITS BIGINT, IN TOTAL_APP_ROLLBACKS BIGINT, IN INT_ROLLBACKS BIGINT, IN TOTAL_RUNSTATS BIGINT, IN TOTAL_REORGS BIGINT, IN TOTAL_LOADS BIGINT) SPECIFIC MONREPORT_COMMONREQMETRICS LANGUAGE SQL BEGIN DECLARE LAST_IR INTEGER; DECLARE IC INTEGER DEFAULT 1; DECLARE TIME_DELTA, CALCVALUE, TOTAL_PROC_TIME DOUBLE; VALUES (DOUBLE(TIMEINTERVAL)) INTO TIME_DELTA; /* ========================== */ /* Work volume and throughput */ /* ========================== */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (TIMEINTERVAL > 0) THEN SET CALCVALUE = DOUBLE(TOTAL_APP_COMMITS)/TIME_DELTA; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),21,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_APP_COMMITS),21,' '); VALUES (IR+1, IC+1) INTO IR, IC; IF (TIMEINTERVAL > 0) THEN SET CALCVALUE = DOUBLE(ACT_COMPLETED_TOTAL)/TIME_DELTA; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),21,' ') || SPACE(2) || RPAD(VARCHAR(ACT_COMPLETED_TOTAL),21,' '); VALUES (IR+1, IC+1) INTO IR, IC; IF (TIMEINTERVAL > 0) THEN SET CALCVALUE = DOUBLE(APP_RQSTS_COMPLETED_TOTAL)/TIME_DELTA; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),21,' ') || SPACE(2) || RPAD(VARCHAR(APP_RQSTS_COMPLETED_TOTAL),21,' '); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_CPU_TIME),''); VALUES (IR+1, IC+1) INTO IR, IC; IF (APP_RQSTS_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = DOUBLE(TOTAL_CPU_TIME)/DOUBLE(APP_RQSTS_COMPLETED_TOTAL); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DECIMAL(CALCVALUE)),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (ROWS_RETURNED > 0) THEN SET CALCVALUE = DOUBLE(ROWS_READ)/DOUBLE(ROWS_RETURNED); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || VARCHAR(DECIMAL(CALCVALUE)) || ' (' || VARCHAR(ROWS_READ) || '/' || VARCHAR(ROWS_RETURNED) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(ROWS_MODIFIED),''); VALUES (IR+1, IC+1) INTO IR, IC; /* ========== */ /* Wait times */ /* ========== */ SET LAST_IR = IR + 7; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (TOTAL_RQST_TIME > 0) THEN SET CALCVALUE = 100 * (DOUBLE(TOTAL_WAIT_TIME)/DOUBLE(TOTAL_RQST_TIME)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(TOTAL_WAIT_TIME) ||  '/' || VARCHAR(TOTAL_RQST_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_ACT_TIME > 0) THEN SET CALCVALUE = 100 * (DOUBLE(TOTAL_ACT_WAIT_TIME)/DOUBLE(TOTAL_ACT_TIME)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(TOTAL_ACT_WAIT_TIME) ||  '/' || VARCHAR(TOTAL_ACT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CLIENT_IDLE_WAIT_TIME),''); VALUES (IR+1, IC+1) INTO IR, IC; IF (TIMEINTERVAL > 0) THEN SET CALCVALUE = DOUBLE(CLIENT_IDLE_WAIT_TIME)/TIME_DELTA; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DECIMAL(CALCVALUE)),''); VALUES (IR+1, IC+1) INTO IR, IC; ELSE SET IC = IC + 1; END IF; SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC] || '100  ' || COALESCE(VARCHAR(TOTAL_WAIT_TIME),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(POOL_READ_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(POOL_READ_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(POOL_WRITE_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(POOL_WRITE_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(DIRECT_READ_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(DIRECT_READ_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(DIRECT_WRITE_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(DIRECT_WRITE_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(LOG_DISK_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(LOG_DISK_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(LOCK_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(LOCK_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(AGENT_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(AGENT_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TCPIP_SEND_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(TCPIP_SEND_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TCPIP_RECV_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(TCPIP_RECV_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(IPC_SEND_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(IPC_SEND_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(IPC_RECV_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(IPC_RECV_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(FCM_SEND_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(FCM_SEND_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(FCM_RECV_WAIT_TIME)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(FCM_RECV_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_WAIT_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(WLM_QUEUE_TIME_TOTAL)/DOUBLE(TOTAL_WAIT_TIME); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),3,' ') || SPACE(2) || VARCHAR(WLM_QUEUE_TIME_TOTAL); VALUES (IR+1, IC+1) INTO IR, IC; /* =============== */ /* Component times */ /* =============== */ SET TOTAL_PROC_TIME = DOUBLE(TOTAL_RQST_TIME - TOTAL_WAIT_TIME); SET LAST_IR = IR + 6; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DECIMAL(TOTAL_PROC_TIME)),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_SECTION_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_SECTION_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_SECTION_SORT_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_SECTION_SORT_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_COMPILE_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_COMPILE_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_IMPLICIT_COMPILE_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || CHAR(TOTAL_IMPLICIT_COMPILE_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_COMMIT_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_COMMIT_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_ROLLBACK_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_ROLLBACK_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_RUNSTATS_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_RUNSTATS_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_REORG_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_REORG_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_PROC_TIME > 0) THEN SET CALCVALUE = 100 * DOUBLE(TOTAL_LOAD_PROC_TIME)/TOTAL_PROC_TIME; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),16,' ') || SPACE(2) || VARCHAR(TOTAL_LOAD_PROC_TIME); VALUES (IR+1, IC+1) INTO IR, IC; /* =========== */ /* Buffer pool */ /* =========== */ SET LAST_IR = IR + 6; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (POOL_DATA_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_DATA_P_READS)/DOUBLE(POOL_DATA_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_DATA_L_READS) || '/' || VARCHAR(POOL_DATA_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; IF (POOL_INDEX_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_INDEX_P_READS)/DOUBLE(POOL_INDEX_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_INDEX_L_READS) || '/' || VARCHAR(POOL_INDEX_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; IF (POOL_XDA_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_XDA_P_READS)/DOUBLE(POOL_XDA_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_XDA_L_READS) || '/' || VARCHAR(POOL_XDA_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; IF (POOL_TEMP_DATA_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_TEMP_DATA_P_READS)/DOUBLE(POOL_TEMP_DATA_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_TEMP_DATA_L_READS) || '/' || VARCHAR(POOL_TEMP_DATA_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; IF (POOL_TEMP_INDEX_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_TEMP_INDEX_P_READS)/DOUBLE(POOL_TEMP_INDEX_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_TEMP_INDEX_L_READS) || '/' || VARCHAR(POOL_TEMP_INDEX_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; IF (POOL_TEMP_XDA_L_READS > 0) THEN SET CALCVALUE = (1-(DOUBLE(POOL_TEMP_XDA_P_READS)/DOUBLE(POOL_TEMP_XDA_L_READS)))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(CHAR(DECIMAL(CALCVALUE)),15,' ') || SPACE(2) || VARCHAR(POOL_TEMP_XDA_L_READS) || '/' || VARCHAR(POOL_TEMP_XDA_P_READS); VALUES (IR+1, IC+1) INTO IR, IC; /* === */ /* I/O */ /* === */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(POOL_DATA_WRITES),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(POOL_XDA_WRITES),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(POOL_INDEX_WRITES),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DIRECT_READS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DIRECT_READ_REQS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DIRECT_WRITES),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DIRECT_WRITE_REQS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(LOG_DISK_WAITS_TOTAL),''); VALUES (IR+1, IC+1) INTO IR, IC; /* ======= */ /* Locking */ /* ======= */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(LOCK_WAIT_TIME)/DOUBLE(ACT_COMPLETED_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),30,' ') || SPACE(2) || VARCHAR(LOCK_WAIT_TIME); VALUES (IR+1, IC+1) INTO IR, IC; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(LOCK_WAITS)/DOUBLE(ACT_COMPLETED_TOTAL))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),30,' ') || SPACE(2) || VARCHAR(LOCK_WAITS); VALUES (IR+1, IC+1) INTO IR, IC; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(LOCK_TIMEOUTS)/DOUBLE(ACT_COMPLETED_TOTAL))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),30,' ') || SPACE(2) || VARCHAR(LOCK_TIMEOUTS); VALUES (IR+1, IC+1) INTO IR, IC; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(DEADLOCKS)/DOUBLE(ACT_COMPLETED_TOTAL))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),30,' ') || SPACE(2) || VARCHAR(DEADLOCKS); VALUES (IR+1, IC+1) INTO IR, IC; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(LOCK_ESCALS)/DOUBLE(ACT_COMPLETED_TOTAL))*100; ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),30,' ') || SPACE(2) || VARCHAR(LOCK_ESCALS); VALUES (IR+1, IC+1) INTO IR, IC; /* ======== */ /* Routines */ /* ======== */ VALUES (IC + 1) INTO IC; SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(TOTAL_ROUTINE_INVOCATIONS)/DOUBLE(ACT_COMPLETED_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),24,' ') || SPACE(2) || VARCHAR(TOTAL_ROUTINE_INVOCATIONS); VALUES (IR+1, IC+1) INTO IR, IC; IF (ACT_COMPLETED_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(TOTAL_ROUTINE_TIME)/DOUBLE(ACT_COMPLETED_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),24,' ') || SPACE(2) || VARCHAR(TOTAL_ROUTINE_TIME); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (TOTAL_ROUTINE_INVOCATIONS > 0) THEN SET CALCVALUE = (DOUBLE(TOTAL_ROUTINE_TIME)/DOUBLE(TOTAL_ROUTINE_INVOCATIONS)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DECIMAL(CALCVALUE)),''); VALUES (IR+1, IC+1) INTO IR, IC; /* ==== */ /* Sort */ /* ==== */ SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_SORTS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(SORT_OVERFLOWS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(POST_THRESHOLD_SORTS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(POST_SHRTHRESHOLD_SORTS),''); VALUES (IR+1, IC+1) INTO IR, IC; /* ======= */ /* Network */ /* ======= */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (TCPIP_SENDS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(TCPIP_SEND_VOLUME)/DOUBLE(TCPIP_SENDS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(TCPIP_SEND_VOLUME)) ||  '/' || RTRIM(VARCHAR(TCPIP_SENDS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; IF (TCPIP_RECVS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(TCPIP_RECV_VOLUME)/DOUBLE(TCPIP_RECVS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(TCPIP_RECV_VOLUME)) ||  '/' || RTRIM(VARCHAR(TCPIP_RECVS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; IF (IPC_SENDS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(IPC_SEND_VOLUME)/DOUBLE(IPC_SENDS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(IPC_SEND_VOLUME)) ||  '/' || RTRIM(VARCHAR(IPC_SENDS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; IF (IPC_RECVS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(IPC_RECV_VOLUME)/DOUBLE(IPC_RECVS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(IPC_RECV_VOLUME)) ||  '/' || RTRIM(VARCHAR(IPC_RECVS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; IF (FCM_SENDS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(FCM_SEND_VOLUME)/DOUBLE(FCM_SENDS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(FCM_SEND_VOLUME)) ||  '/' || RTRIM(VARCHAR(FCM_SENDS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; IF (FCM_RECVS_TOTAL > 0) THEN SET CALCVALUE = (DOUBLE(FCM_RECV_VOLUME)/DOUBLE(FCM_RECVS_TOTAL)); ELSE SET CALCVALUE = 0; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC] || RPAD(VARCHAR(DECIMAL(CALCVALUE)),11,' ') || '(' || RTRIM(VARCHAR(FCM_RECV_VOLUME)) ||  '/' || RTRIM(VARCHAR(FCM_RECVS_TOTAL)) || ')'; VALUES (IR+1, IC+1) INTO IR, IC; /* ===== */ /* Other */ /* ===== */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_COMPILATIONS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(PKG_CACHE_INSERTS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(PKG_CACHE_LOOKUPS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CAT_CACHE_INSERTS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CAT_CACHE_LOOKUPS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_APP_COMMITS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(INT_COMMITS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_APP_ROLLBACKS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(INT_ROLLBACKS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(NUM_LOG_BUFFER_FULL),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(ACT_ABORTED_TOTAL),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(ACT_REJECTED_TOTAL),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(WLM_QUEUE_ASSIGNMENTS_TOTAL),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(WLM_QUEUE_TIME_TOTAL),''); VALUES (IR+1, IC+1) INTO IR, IC; /* ====================== */ /* DB2 utility operations */ /* ====================== */ SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_RUNSTATS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_REORGS),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TOTAL_LOADS),''); VALUES (IR+1, IC+1) INTO IR, IC; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	PROCEDURE  CONNDELTAS ( IN TIMEINTERVAL INTEGER, IN APP_HANDLE BIGINT, IN DBMEMBER INTEGER, /* connection identifiers and other details */ INOUT APPLICATION_HANDLE_ARRAY MONMETRICS_BIGINT_TYPE, INOUT APPLICATION_NAME_ARRAY MONMETRICS_CHAR128_TYPE, INOUT APPLICATION_ID_ARRAY MONMETRICS_CHAR128_TYPE, INOUT SYSTEM_AUTH_ID_ARRAY MONMETRICS_CHAR128_TYPE, INOUT SESSION_AUTH_ID_ARRAY MONMETRICS_CHAR128_TYPE, INOUT CLIENT_ACCTNG_ARRAY MONMETRICS_CHAR255_TYPE, INOUT CLIENT_USERID_ARRAY MONMETRICS_CHAR255_TYPE, INOUT CLIENT_APPLNAME_ARRAY MONMETRICS_CHAR255_TYPE, INOUT CLIENT_WRKSTNNAME_ARRAY MONMETRICS_CHAR255_TYPE, INOUT CLIENT_PID_ARRAY MONMETRICS_BIGINT_TYPE, INOUT CLIENT_PRDID_ARRAY MONMETRICS_CHAR128_TYPE, INOUT CLIENT_PLATFORM_ARRAY MONMETRICS_CHAR12_TYPE, INOUT CLIENT_PROTOCOL_ARRAY MONMETRICS_CHAR10_TYPE, INOUT CONNECTION_START_TIME_ARRAY MONMETRICS_TIMESTAMP_TYPE, INOUT NUM_LOCKS_HELD_ARRAY MONMETRICS_BIGINT_TYPE, /* common req metrics */ INOUT WLM_QUEUE_TIME_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT AGENT_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_RECVS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_SENDS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_RECVS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_SENDS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_SEND_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_RECV_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_SEND_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_RECV_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_RECV_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_RECV_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TCPIP_SEND_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT IPC_SEND_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOCK_ESCALS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOCK_WAITS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOCK_TIMEOUTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DEADLOCKS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ACT_COMPLETED_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ACT_ABORTED_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ACT_REJECTED_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT APP_RQSTS_COMPLETED_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_RQST_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_CPU_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_ACT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_ACT_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ROWS_READ_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ROWS_RETURNED_ARRAY MONMETRICS_BIGINT_TYPE, INOUT ROWS_MODIFIED_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_DATA_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_INDEX_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_DATA_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_INDEX_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_XDA_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_XDA_L_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_DATA_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_INDEX_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_DATA_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_INDEX_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_TEMP_XDA_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_XDA_P_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_READ_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_WRITE_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_DATA_WRITES_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_INDEX_WRITES_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POOL_XDA_WRITES_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_READ_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_READS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_READ_REQS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_WRITE_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_WRITES_ARRAY MONMETRICS_BIGINT_TYPE, INOUT DIRECT_WRITE_REQS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOG_DISK_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOG_DISK_WAITS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT NUM_LOG_BUFFER_FULL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT CLIENT_IDLE_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT LOCK_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_SEND_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_SORTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT SORT_OVERFLOWS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POST_THRESHOLD_SORTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT POST_SHRTHRESHOLD_SORTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_SEND_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_SENDS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_RECV_VOLUME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_RECVS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY MONMETRICS_BIGINT_TYPE, INOUT FCM_RECV_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_SECTION_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_SECTION_SORT_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_COMPILE_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_COMMIT_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_ROLLBACK_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_RUNSTATS_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_REORG_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_LOAD_PROC_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_APP_COMMITS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_ROUTINE_INVOCATIONS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_ROUTINE_TIME_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_COMPILATIONS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT PKG_CACHE_INSERTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT PKG_CACHE_LOOKUPS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT CAT_CACHE_INSERTS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT CAT_CACHE_LOOKUPS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT INT_COMMITS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_APP_ROLLBACKS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT INT_ROLLBACKS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_RUNSTATS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_REORGS_ARRAY MONMETRICS_BIGINT_TYPE, INOUT TOTAL_LOADS_ARRAY MONMETRICS_BIGINT_TYPE) SPECIFIC MONREPORT_CONNDELTAS LANGUAGE SQL BEGIN /* collect connection details and metrics at start of interval */ SELECT ARRAY_AGG(I.APPLICATION_HANDLE ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.APPLICATION_NAME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.APPLICATION_ID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.SYSTEM_AUTH_ID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.SESSION_AUTH_ID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_ACCTNG ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_USERID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_APPLNAME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_WRKSTNNAME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_PID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_PRDID ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_PLATFORM ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CLIENT_PROTOCOL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.CONNECTION_START_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(I.NUM_LOCKS_HELD ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.WLM_QUEUE_TIME_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.AGENT_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_RECVS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_SENDS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_RECVS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_SENDS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_SEND_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_RECV_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_SEND_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_RECV_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_RECV_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_RECV_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TCPIP_SEND_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.IPC_SEND_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOCK_ESCALS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOCK_WAITS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOCK_TIMEOUTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DEADLOCKS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ACT_COMPLETED_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ACT_ABORTED_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ACT_REJECTED_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.APP_RQSTS_COMPLETED_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_RQST_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_CPU_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_ACT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_ACT_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ROWS_READ ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ROWS_RETURNED ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.ROWS_MODIFIED ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_DATA_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_INDEX_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_DATA_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_INDEX_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_XDA_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_XDA_L_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_DATA_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_INDEX_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_DATA_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_INDEX_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_TEMP_XDA_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_XDA_P_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_READ_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_WRITE_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_DATA_WRITES ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_INDEX_WRITES ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POOL_XDA_WRITES ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_READ_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_READS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_READ_REQS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_WRITE_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_WRITES ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.DIRECT_WRITE_REQS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOG_DISK_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOG_DISK_WAITS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.NUM_LOG_BUFFER_FULL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.CLIENT_IDLE_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.LOCK_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_SEND_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_SORTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.SORT_OVERFLOWS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POST_THRESHOLD_SORTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.POST_SHRTHRESHOLD_SORTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_SEND_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_SENDS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_RECV_VOLUME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_RECVS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.WLM_QUEUE_ASSIGNMENTS_TOTAL ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.FCM_RECV_WAIT_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_SECTION_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_SECTION_SORT_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_COMPILE_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_IMPLICIT_COMPILE_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_COMMIT_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_ROLLBACK_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_RUNSTATS_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_REORG_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_LOAD_PROC_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_APP_COMMITS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_ROUTINE_INVOCATIONS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_ROUTINE_TIME ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_COMPILATIONS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.PKG_CACHE_INSERTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.PKG_CACHE_LOOKUPS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.CAT_CACHE_INSERTS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.CAT_CACHE_LOOKUPS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.INT_COMMITS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_APP_ROLLBACKS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.INT_ROLLBACKS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_RUNSTATS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_REORGS ORDER BY I.APPLICATION_HANDLE), ARRAY_AGG(M.TOTAL_LOADS ORDER BY I.APPLICATION_HANDLE) INTO APPLICATION_HANDLE_ARRAY, APPLICATION_NAME_ARRAY, APPLICATION_ID_ARRAY, SYSTEM_AUTH_ID_ARRAY, SESSION_AUTH_ID_ARRAY, CLIENT_ACCTNG_ARRAY, CLIENT_USERID_ARRAY, CLIENT_APPLNAME_ARRAY, CLIENT_WRKSTNNAME_ARRAY, CLIENT_PID_ARRAY, CLIENT_PRDID_ARRAY, CLIENT_PLATFORM_ARRAY, CLIENT_PROTOCOL_ARRAY, CONNECTION_START_TIME_ARRAY, NUM_LOCKS_HELD_ARRAY, WLM_QUEUE_TIME_TOTAL_ARRAY, AGENT_WAIT_TIME_ARRAY, TCPIP_RECVS_TOTAL_ARRAY, TCPIP_SENDS_TOTAL_ARRAY, IPC_RECVS_TOTAL_ARRAY, IPC_SENDS_TOTAL_ARRAY, TCPIP_SEND_WAIT_TIME_ARRAY, TCPIP_RECV_WAIT_TIME_ARRAY, IPC_SEND_WAIT_TIME_ARRAY, IPC_RECV_WAIT_TIME_ARRAY, TCPIP_RECV_VOLUME_ARRAY, IPC_RECV_VOLUME_ARRAY, TCPIP_SEND_VOLUME_ARRAY, IPC_SEND_VOLUME_ARRAY, LOCK_ESCALS_ARRAY, LOCK_WAITS_ARRAY, LOCK_TIMEOUTS_ARRAY, DEADLOCKS_ARRAY, ACT_COMPLETED_TOTAL_ARRAY, ACT_ABORTED_TOTAL_ARRAY, ACT_REJECTED_TOTAL_ARRAY, APP_RQSTS_COMPLETED_TOTAL_ARRAY, TOTAL_RQST_TIME_ARRAY, TOTAL_CPU_TIME_ARRAY, TOTAL_WAIT_TIME_ARRAY, TOTAL_ACT_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, ROWS_READ_ARRAY, ROWS_RETURNED_ARRAY, ROWS_MODIFIED_ARRAY, POOL_DATA_L_READS_ARRAY, POOL_INDEX_L_READS_ARRAY, POOL_TEMP_DATA_L_READS_ARRAY, POOL_TEMP_INDEX_L_READS_ARRAY, POOL_TEMP_XDA_L_READS_ARRAY, POOL_XDA_L_READS_ARRAY, POOL_DATA_P_READS_ARRAY, POOL_INDEX_P_READS_ARRAY, POOL_TEMP_DATA_P_READS_ARRAY, POOL_TEMP_INDEX_P_READS_ARRAY, POOL_TEMP_XDA_P_READS_ARRAY, POOL_XDA_P_READS_ARRAY, POOL_READ_TIME_ARRAY, POOL_WRITE_TIME_ARRAY, POOL_DATA_WRITES_ARRAY, POOL_INDEX_WRITES_ARRAY, POOL_XDA_WRITES_ARRAY, DIRECT_READ_TIME_ARRAY, DIRECT_READS_ARRAY, DIRECT_READ_REQS_ARRAY, DIRECT_WRITE_TIME_ARRAY, DIRECT_WRITES_ARRAY, DIRECT_WRITE_REQS_ARRAY, LOG_DISK_WAIT_TIME_ARRAY, LOG_DISK_WAITS_TOTAL_ARRAY, NUM_LOG_BUFFER_FULL_ARRAY, CLIENT_IDLE_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, FCM_SEND_WAIT_TIME_ARRAY, TOTAL_SORTS_ARRAY, SORT_OVERFLOWS_ARRAY, POST_THRESHOLD_SORTS_ARRAY, POST_SHRTHRESHOLD_SORTS_ARRAY, FCM_SEND_VOLUME_ARRAY, FCM_SENDS_TOTAL_ARRAY, FCM_RECV_VOLUME_ARRAY, FCM_RECVS_TOTAL_ARRAY, WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY, FCM_RECV_WAIT_TIME_ARRAY, TOTAL_SECTION_PROC_TIME_ARRAY, TOTAL_SECTION_SORT_PROC_TIME_ARRAY, TOTAL_COMPILE_PROC_TIME_ARRAY, TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY, TOTAL_COMMIT_PROC_TIME_ARRAY, TOTAL_ROLLBACK_PROC_TIME_ARRAY, TOTAL_RUNSTATS_PROC_TIME_ARRAY, TOTAL_REORG_PROC_TIME_ARRAY, TOTAL_LOAD_PROC_TIME_ARRAY, TOTAL_APP_COMMITS_ARRAY, TOTAL_ROUTINE_INVOCATIONS_ARRAY, TOTAL_ROUTINE_TIME_ARRAY, TOTAL_COMPILATIONS_ARRAY, PKG_CACHE_INSERTS_ARRAY, PKG_CACHE_LOOKUPS_ARRAY, CAT_CACHE_INSERTS_ARRAY, CAT_CACHE_LOOKUPS_ARRAY, INT_COMMITS_ARRAY, TOTAL_APP_ROLLBACKS_ARRAY, INT_ROLLBACKS_ARRAY, TOTAL_RUNSTATS_ARRAY, TOTAL_REORGS_ARRAY, TOTAL_LOADS_ARRAY /* I is used to get the connection identifiers and other details */ FROM TABLE(MON_GET_CONNECTION(APP_HANDLE, DBMEMBER)) AS I, /* M (below) is used to collect the metrics */ (SELECT APPLICATION_HANDLE, COORD_MEMBER, /* this is only used to join M with I */ SUM(WLM_QUEUE_TIME_TOTAL) AS WLM_QUEUE_TIME_TOTAL, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(TCPIP_RECVS_TOTAL) AS TCPIP_RECVS_TOTAL, SUM(TCPIP_SENDS_TOTAL) AS TCPIP_SENDS_TOTAL, SUM(IPC_RECVS_TOTAL) AS IPC_RECVS_TOTAL, SUM(IPC_SENDS_TOTAL) AS IPC_SENDS_TOTAL, SUM(TCPIP_SEND_WAIT_TIME) AS TCPIP_SEND_WAIT_TIME, SUM(TCPIP_RECV_WAIT_TIME) AS TCPIP_RECV_WAIT_TIME, SUM(IPC_SEND_WAIT_TIME) AS IPC_SEND_WAIT_TIME, SUM(IPC_RECV_WAIT_TIME) AS IPC_RECV_WAIT_TIME, SUM(TCPIP_RECV_VOLUME) AS TCPIP_RECV_VOLUME, SUM(IPC_RECV_VOLUME) AS IPC_RECV_VOLUME, SUM(TCPIP_SEND_VOLUME) AS TCPIP_SEND_VOLUME, SUM(IPC_SEND_VOLUME) AS IPC_SEND_VOLUME, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_ABORTED_TOTAL) AS ACT_ABORTED_TOTAL, SUM(ACT_REJECTED_TOTAL) AS ACT_REJECTED_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(POOL_DATA_L_READS) AS POOL_DATA_L_READS, SUM(POOL_INDEX_L_READS) AS POOL_INDEX_L_READS, SUM(POOL_TEMP_DATA_L_READS) AS POOL_TEMP_DATA_L_READS, SUM(POOL_TEMP_INDEX_L_READS) AS POOL_TEMP_INDEX_L_READS, SUM(POOL_TEMP_XDA_L_READS) AS POOL_TEMP_XDA_L_READS, SUM(POOL_XDA_L_READS) AS POOL_XDA_L_READS, SUM(POOL_DATA_P_READS) AS POOL_DATA_P_READS, SUM(POOL_INDEX_P_READS) AS POOL_INDEX_P_READS, SUM(POOL_TEMP_DATA_P_READS) AS POOL_TEMP_DATA_P_READS, SUM(POOL_TEMP_INDEX_P_READS) AS POOL_TEMP_INDEX_P_READS, SUM(POOL_TEMP_XDA_P_READS) AS POOL_TEMP_XDA_P_READS, SUM(POOL_XDA_P_READS) AS POOL_XDA_P_READS, SUM(POOL_READ_TIME) AS POOL_READ_TIME, SUM(POOL_WRITE_TIME) AS POOL_WRITE_TIME, SUM(POOL_DATA_WRITES) AS POOL_DATA_WRITES, SUM(POOL_INDEX_WRITES) AS POOL_INDEX_WRITES, SUM(POOL_XDA_WRITES) AS POOL_XDA_WRITES, SUM(DIRECT_READ_TIME) AS DIRECT_READ_TIME, SUM(DIRECT_READS) AS DIRECT_READS, SUM(DIRECT_READ_REQS) AS DIRECT_READ_REQS, SUM(DIRECT_WRITE_TIME) AS DIRECT_WRITE_TIME, SUM(DIRECT_WRITES) AS DIRECT_WRITES, SUM(DIRECT_WRITE_REQS) AS DIRECT_WRITE_REQS, SUM(LOG_DISK_WAIT_TIME) AS LOG_DISK_WAIT_TIME, SUM(LOG_DISK_WAITS_TOTAL) AS LOG_DISK_WAITS_TOTAL, SUM(NUM_LOG_BUFFER_FULL) AS NUM_LOG_BUFFER_FULL, SUM(CLIENT_IDLE_WAIT_TIME) AS CLIENT_IDLE_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(FCM_SEND_WAIT_TIME) AS FCM_SEND_WAIT_TIME, SUM(TOTAL_SORTS) AS TOTAL_SORTS, SUM(SORT_OVERFLOWS) AS SORT_OVERFLOWS, SUM(POST_THRESHOLD_SORTS) AS POST_THRESHOLD_SORTS, SUM(POST_SHRTHRESHOLD_SORTS) AS POST_SHRTHRESHOLD_SORTS, SUM(FCM_SEND_VOLUME) AS FCM_SEND_VOLUME, SUM(FCM_SENDS_TOTAL) AS FCM_SENDS_TOTAL, SUM(FCM_RECV_VOLUME) AS FCM_RECV_VOLUME, SUM(FCM_RECVS_TOTAL) AS FCM_RECVS_TOTAL, SUM(WLM_QUEUE_ASSIGNMENTS_TOTAL) AS WLM_QUEUE_ASSIGNMENTS_TOTAL, SUM(FCM_RECV_WAIT_TIME) AS FCM_RECV_WAIT_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS TOTAL_SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS TOTAL_SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME) AS TOTAL_COMPILE_PROC_TIME, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS TOTAL_IMPLICIT_COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME) AS TOTAL_COMMIT_PROC_TIME, SUM(TOTAL_ROLLBACK_PROC_TIME) AS TOTAL_ROLLBACK_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME) AS TOTAL_RUNSTATS_PROC_TIME, SUM(TOTAL_REORG_PROC_TIME) AS TOTAL_REORG_PROC_TIME, SUM(TOTAL_LOAD_PROC_TIME) AS TOTAL_LOAD_PROC_TIME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_ROUTINE_INVOCATIONS) AS TOTAL_ROUTINE_INVOCATIONS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME, SUM(TOTAL_COMPILATIONS) AS TOTAL_COMPILATIONS, SUM(PKG_CACHE_INSERTS) AS PKG_CACHE_INSERTS, SUM(PKG_CACHE_LOOKUPS) AS PKG_CACHE_LOOKUPS, SUM(CAT_CACHE_INSERTS) AS CAT_CACHE_INSERTS, SUM(CAT_CACHE_LOOKUPS) AS CAT_CACHE_LOOKUPS, SUM(INT_COMMITS) AS INT_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(INT_ROLLBACKS) AS INT_ROLLBACKS, SUM(TOTAL_RUNSTATS) AS TOTAL_RUNSTATS, SUM(TOTAL_REORGS) AS TOTAL_REORGS, SUM(TOTAL_LOADS) AS TOTAL_LOADS FROM TABLE(MON_GET_CONNECTION(APP_HANDLE, DBMEMBER)) GROUP BY APPLICATION_HANDLE, COORD_MEMBER ) AS M WHERE I.APPLICATION_HANDLE = M.APPLICATION_HANDLE AND I.MEMBER = M.COORD_MEMBER; IF (TIMEINTERVAL > 0) THEN CALL DBMS_ALERT.SLEEP(TIMEINTERVAL); /* collect metrics again (but not connection details) and compute difference */ SELECT ARRAY_AGG(APPLICATION_HANDLE ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APPLICATION_NAME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APPLICATION_ID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(SYSTEM_AUTH_ID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(SESSION_AUTH_ID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_ACCTNG ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_USERID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_APPLNAME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_WRKSTNNAME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_PID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_PRDID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_PLATFORM ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_PROTOCOL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CONNECTION_START_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(NUM_LOCKS_HELD ORDER BY APPLICATION_HANDLE), ARRAY_AGG(WLM_QUEUE_TIME_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(AGENT_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_RECVS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_SENDS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_RECVS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_SENDS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_SEND_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_RECV_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_SEND_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_RECV_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_RECV_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_RECV_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TCPIP_SEND_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(IPC_SEND_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOCK_ESCALS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOCK_WAITS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOCK_TIMEOUTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DEADLOCKS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ACT_COMPLETED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ACT_ABORTED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ACT_REJECTED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_ACT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_ACT_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_READ ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_RETURNED ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_MODIFIED ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_DATA_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_INDEX_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_DATA_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_INDEX_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_XDA_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_XDA_L_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_DATA_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_INDEX_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_DATA_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_INDEX_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_TEMP_XDA_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_XDA_P_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_READ_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_WRITE_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_DATA_WRITES ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_INDEX_WRITES ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POOL_XDA_WRITES ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_READ_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_READS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_READ_REQS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_WRITE_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_WRITES ORDER BY APPLICATION_HANDLE), ARRAY_AGG(DIRECT_WRITE_REQS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOG_DISK_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOG_DISK_WAITS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(NUM_LOG_BUFFER_FULL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CLIENT_IDLE_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(LOCK_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_SEND_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_SORTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(SORT_OVERFLOWS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POST_THRESHOLD_SORTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(POST_SHRTHRESHOLD_SORTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_SEND_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_SENDS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_RECV_VOLUME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_RECVS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(WLM_QUEUE_ASSIGNMENTS_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(FCM_RECV_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_SECTION_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_SECTION_SORT_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_COMPILE_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_IMPLICIT_COMPILE_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_COMMIT_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_ROLLBACK_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_RUNSTATS_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_REORG_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_LOAD_PROC_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_ROUTINE_INVOCATIONS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_ROUTINE_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_COMPILATIONS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(PKG_CACHE_INSERTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(PKG_CACHE_LOOKUPS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CAT_CACHE_INSERTS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(CAT_CACHE_LOOKUPS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(INT_COMMITS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_APP_ROLLBACKS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(INT_ROLLBACKS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_RUNSTATS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_REORGS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_LOADS ORDER BY APPLICATION_HANDLE) INTO APPLICATION_HANDLE_ARRAY, APPLICATION_NAME_ARRAY, APPLICATION_ID_ARRAY, SYSTEM_AUTH_ID_ARRAY, SESSION_AUTH_ID_ARRAY, CLIENT_ACCTNG_ARRAY, CLIENT_USERID_ARRAY, CLIENT_APPLNAME_ARRAY, CLIENT_WRKSTNNAME_ARRAY, CLIENT_PID_ARRAY, CLIENT_PRDID_ARRAY, CLIENT_PLATFORM_ARRAY, CLIENT_PROTOCOL_ARRAY, CONNECTION_START_TIME_ARRAY, NUM_LOCKS_HELD_ARRAY, WLM_QUEUE_TIME_TOTAL_ARRAY, AGENT_WAIT_TIME_ARRAY, TCPIP_RECVS_TOTAL_ARRAY, TCPIP_SENDS_TOTAL_ARRAY, IPC_RECVS_TOTAL_ARRAY, IPC_SENDS_TOTAL_ARRAY, TCPIP_SEND_WAIT_TIME_ARRAY, TCPIP_RECV_WAIT_TIME_ARRAY, IPC_SEND_WAIT_TIME_ARRAY, IPC_RECV_WAIT_TIME_ARRAY, TCPIP_RECV_VOLUME_ARRAY, IPC_RECV_VOLUME_ARRAY, TCPIP_SEND_VOLUME_ARRAY, IPC_SEND_VOLUME_ARRAY, LOCK_ESCALS_ARRAY, LOCK_WAITS_ARRAY, LOCK_TIMEOUTS_ARRAY, DEADLOCKS_ARRAY, ACT_COMPLETED_TOTAL_ARRAY, ACT_ABORTED_TOTAL_ARRAY, ACT_REJECTED_TOTAL_ARRAY, APP_RQSTS_COMPLETED_TOTAL_ARRAY, TOTAL_RQST_TIME_ARRAY, TOTAL_CPU_TIME_ARRAY, TOTAL_WAIT_TIME_ARRAY, TOTAL_ACT_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, ROWS_READ_ARRAY, ROWS_RETURNED_ARRAY, ROWS_MODIFIED_ARRAY, POOL_DATA_L_READS_ARRAY, POOL_INDEX_L_READS_ARRAY, POOL_TEMP_DATA_L_READS_ARRAY, POOL_TEMP_INDEX_L_READS_ARRAY, POOL_TEMP_XDA_L_READS_ARRAY, POOL_XDA_L_READS_ARRAY, POOL_DATA_P_READS_ARRAY, POOL_INDEX_P_READS_ARRAY, POOL_TEMP_DATA_P_READS_ARRAY, POOL_TEMP_INDEX_P_READS_ARRAY, POOL_TEMP_XDA_P_READS_ARRAY, POOL_XDA_P_READS_ARRAY, POOL_READ_TIME_ARRAY, POOL_WRITE_TIME_ARRAY, POOL_DATA_WRITES_ARRAY, POOL_INDEX_WRITES_ARRAY, POOL_XDA_WRITES_ARRAY, DIRECT_READ_TIME_ARRAY, DIRECT_READS_ARRAY, DIRECT_READ_REQS_ARRAY, DIRECT_WRITE_TIME_ARRAY, DIRECT_WRITES_ARRAY, DIRECT_WRITE_REQS_ARRAY, LOG_DISK_WAIT_TIME_ARRAY, LOG_DISK_WAITS_TOTAL_ARRAY, NUM_LOG_BUFFER_FULL_ARRAY, CLIENT_IDLE_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, FCM_SEND_WAIT_TIME_ARRAY, TOTAL_SORTS_ARRAY, SORT_OVERFLOWS_ARRAY, POST_THRESHOLD_SORTS_ARRAY, POST_SHRTHRESHOLD_SORTS_ARRAY, FCM_SEND_VOLUME_ARRAY, FCM_SENDS_TOTAL_ARRAY, FCM_RECV_VOLUME_ARRAY, FCM_RECVS_TOTAL_ARRAY, WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY, FCM_RECV_WAIT_TIME_ARRAY, TOTAL_SECTION_PROC_TIME_ARRAY, TOTAL_SECTION_SORT_PROC_TIME_ARRAY, TOTAL_COMPILE_PROC_TIME_ARRAY, TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY, TOTAL_COMMIT_PROC_TIME_ARRAY, TOTAL_ROLLBACK_PROC_TIME_ARRAY, TOTAL_RUNSTATS_PROC_TIME_ARRAY, TOTAL_REORG_PROC_TIME_ARRAY, TOTAL_LOAD_PROC_TIME_ARRAY, TOTAL_APP_COMMITS_ARRAY, TOTAL_ROUTINE_INVOCATIONS_ARRAY, TOTAL_ROUTINE_TIME_ARRAY, TOTAL_COMPILATIONS_ARRAY, PKG_CACHE_INSERTS_ARRAY, PKG_CACHE_LOOKUPS_ARRAY, CAT_CACHE_INSERTS_ARRAY, CAT_CACHE_LOOKUPS_ARRAY, INT_COMMITS_ARRAY, TOTAL_APP_ROLLBACKS_ARRAY, INT_ROLLBACKS_ARRAY, TOTAL_RUNSTATS_ARRAY, TOTAL_REORGS_ARRAY, TOTAL_LOADS_ARRAY FROM (SELECT A.APPLICATION_HANDLE, A.APPLICATION_NAME, A.APPLICATION_ID, A.SYSTEM_AUTH_ID, A.SESSION_AUTH_ID, A.CLIENT_ACCTNG, A.CLIENT_USERID, A.CLIENT_APPLNAME, A.CLIENT_WRKSTNNAME, A.CLIENT_PID, A.CLIENT_PRDID, A.CLIENT_PLATFORM, A.CLIENT_PROTOCOL, A.CONNECTION_START_TIME, A.NUM_LOCKS_HELD, B.WLM_QUEUE_TIME_TOTAL - A.WLM_QUEUE_TIME_TOTAL AS WLM_QUEUE_TIME_TOTAL, B.AGENT_WAIT_TIME - A.AGENT_WAIT_TIME AS AGENT_WAIT_TIME, B.TCPIP_RECVS_TOTAL - A.TCPIP_RECVS_TOTAL AS TCPIP_RECVS_TOTAL, B.TCPIP_SENDS_TOTAL - A.TCPIP_SENDS_TOTAL AS TCPIP_SENDS_TOTAL, B.IPC_RECVS_TOTAL - A.IPC_RECVS_TOTAL AS IPC_RECVS_TOTAL, B.IPC_SENDS_TOTAL - A.IPC_SENDS_TOTAL AS IPC_SENDS_TOTAL, B.TCPIP_SEND_WAIT_TIME - A.TCPIP_SEND_WAIT_TIME AS TCPIP_SEND_WAIT_TIME, B.TCPIP_RECV_WAIT_TIME - A.TCPIP_RECV_WAIT_TIME AS TCPIP_RECV_WAIT_TIME, B.IPC_SEND_WAIT_TIME - A.IPC_SEND_WAIT_TIME AS IPC_SEND_WAIT_TIME, B.IPC_RECV_WAIT_TIME - A.IPC_RECV_WAIT_TIME AS IPC_RECV_WAIT_TIME, B.TCPIP_RECV_VOLUME - A.TCPIP_RECV_VOLUME AS TCPIP_RECV_VOLUME, B.IPC_RECV_VOLUME - A.IPC_RECV_VOLUME AS IPC_RECV_VOLUME, B.TCPIP_SEND_VOLUME - A.TCPIP_SEND_VOLUME AS TCPIP_SEND_VOLUME, B.IPC_SEND_VOLUME - A.IPC_SEND_VOLUME AS IPC_SEND_VOLUME, B.LOCK_ESCALS - A.LOCK_ESCALS AS LOCK_ESCALS, B.LOCK_WAITS - A.LOCK_WAITS AS LOCK_WAITS, B.LOCK_TIMEOUTS - A.LOCK_TIMEOUTS AS LOCK_TIMEOUTS, B.DEADLOCKS - A.DEADLOCKS AS DEADLOCKS, B.ACT_COMPLETED_TOTAL - A.ACT_COMPLETED_TOTAL AS ACT_COMPLETED_TOTAL, B.ACT_ABORTED_TOTAL - A.ACT_ABORTED_TOTAL AS ACT_ABORTED_TOTAL, B.ACT_REJECTED_TOTAL - A.ACT_REJECTED_TOTAL AS ACT_REJECTED_TOTAL, B.APP_RQSTS_COMPLETED_TOTAL - A.APP_RQSTS_COMPLETED_TOTAL AS APP_RQSTS_COMPLETED_TOTAL, B.TOTAL_RQST_TIME - A.TOTAL_RQST_TIME AS TOTAL_RQST_TIME, B.TOTAL_CPU_TIME - A.TOTAL_CPU_TIME AS TOTAL_CPU_TIME, B.TOTAL_WAIT_TIME - A.TOTAL_WAIT_TIME AS TOTAL_WAIT_TIME, B.TOTAL_ACT_TIME - A.TOTAL_ACT_TIME AS TOTAL_ACT_TIME, B.TOTAL_ACT_WAIT_TIME - A.TOTAL_ACT_WAIT_TIME AS TOTAL_ACT_WAIT_TIME, B.ROWS_READ - A.ROWS_READ AS ROWS_READ, B.ROWS_RETURNED - A.ROWS_RETURNED AS ROWS_RETURNED, B.ROWS_MODIFIED - A.ROWS_MODIFIED AS ROWS_MODIFIED, B.POOL_DATA_L_READS - A.POOL_DATA_L_READS AS POOL_DATA_L_READS, B.POOL_INDEX_L_READS - A.POOL_INDEX_L_READS AS POOL_INDEX_L_READS, B.POOL_TEMP_DATA_L_READS - A.POOL_TEMP_DATA_L_READS AS POOL_TEMP_DATA_L_READS, B.POOL_TEMP_INDEX_L_READS - A.POOL_TEMP_INDEX_L_READS AS POOL_TEMP_INDEX_L_READS, B.POOL_TEMP_XDA_L_READS - A.POOL_TEMP_XDA_L_READS AS POOL_TEMP_XDA_L_READS, B.POOL_XDA_L_READS - A.POOL_XDA_L_READS AS POOL_XDA_L_READS, B.POOL_DATA_P_READS - A.POOL_DATA_P_READS AS POOL_DATA_P_READS, B.POOL_INDEX_P_READS - A.POOL_INDEX_P_READS AS POOL_INDEX_P_READS, B.POOL_TEMP_DATA_P_READS - A.POOL_TEMP_DATA_P_READS AS POOL_TEMP_DATA_P_READS, B.POOL_TEMP_INDEX_P_READS - A.POOL_TEMP_INDEX_P_READS AS POOL_TEMP_INDEX_P_READS, B.POOL_TEMP_XDA_P_READS - A.POOL_TEMP_XDA_P_READS AS POOL_TEMP_XDA_P_READS, B.POOL_XDA_P_READS - A.POOL_XDA_P_READS AS POOL_XDA_P_READS, B.POOL_READ_TIME - A.POOL_READ_TIME AS POOL_READ_TIME, B.POOL_WRITE_TIME - A.POOL_WRITE_TIME AS POOL_WRITE_TIME, B.POOL_DATA_WRITES - A.POOL_DATA_WRITES AS POOL_DATA_WRITES, B.POOL_INDEX_WRITES - A.POOL_INDEX_WRITES AS POOL_INDEX_WRITES, B.POOL_XDA_WRITES - A.POOL_XDA_WRITES AS POOL_XDA_WRITES, B.DIRECT_READ_TIME - A.DIRECT_READ_TIME AS DIRECT_READ_TIME, B.DIRECT_READS - A.DIRECT_READS AS DIRECT_READS, B.DIRECT_READ_REQS - A.DIRECT_READ_REQS AS DIRECT_READ_REQS, B.DIRECT_WRITE_TIME - A.DIRECT_WRITE_TIME AS DIRECT_WRITE_TIME, B.DIRECT_WRITES - A.DIRECT_WRITES AS DIRECT_WRITES, B.DIRECT_WRITE_REQS - A.DIRECT_WRITE_REQS AS DIRECT_WRITE_REQS, B.LOG_DISK_WAIT_TIME - A.LOG_DISK_WAIT_TIME AS LOG_DISK_WAIT_TIME, B.LOG_DISK_WAITS_TOTAL - A.LOG_DISK_WAITS_TOTAL AS LOG_DISK_WAITS_TOTAL, B.NUM_LOG_BUFFER_FULL - A.NUM_LOG_BUFFER_FULL AS NUM_LOG_BUFFER_FULL, B.CLIENT_IDLE_WAIT_TIME - A.CLIENT_IDLE_WAIT_TIME AS CLIENT_IDLE_WAIT_TIME, B.LOCK_WAIT_TIME - A.LOCK_WAIT_TIME AS LOCK_WAIT_TIME, B.FCM_SEND_WAIT_TIME - A.FCM_SEND_WAIT_TIME AS FCM_SEND_WAIT_TIME, B.TOTAL_SORTS - A.TOTAL_SORTS AS TOTAL_SORTS, B.SORT_OVERFLOWS - A.SORT_OVERFLOWS AS SORT_OVERFLOWS, B.POST_THRESHOLD_SORTS - A.POST_THRESHOLD_SORTS AS POST_THRESHOLD_SORTS, B.POST_SHRTHRESHOLD_SORTS - A.POST_SHRTHRESHOLD_SORTS AS POST_SHRTHRESHOLD_SORTS, B.FCM_SEND_VOLUME - A.FCM_SEND_VOLUME AS FCM_SEND_VOLUME, B.FCM_SENDS_TOTAL - A.FCM_SENDS_TOTAL AS FCM_SENDS_TOTAL, B.FCM_RECV_VOLUME - A.FCM_RECV_VOLUME AS FCM_RECV_VOLUME, B.FCM_RECVS_TOTAL - A.FCM_RECVS_TOTAL AS FCM_RECVS_TOTAL, B.WLM_QUEUE_ASSIGNMENTS_TOTAL - A.WLM_QUEUE_ASSIGNMENTS_TOTAL AS WLM_QUEUE_ASSIGNMENTS_TOTAL, B.FCM_RECV_WAIT_TIME - A.FCM_RECV_WAIT_TIME AS FCM_RECV_WAIT_TIME, B.TOTAL_SECTION_PROC_TIME - A.TOTAL_SECTION_PROC_TIME AS TOTAL_SECTION_PROC_TIME, B.TOTAL_SECTION_SORT_PROC_TIME - A.TOTAL_SECTION_SORT_PROC_TIME AS TOTAL_SECTION_SORT_PROC_TIME, B.TOTAL_COMPILE_PROC_TIME - A.TOTAL_COMPILE_PROC_TIME AS TOTAL_COMPILE_PROC_TIME, B.TOTAL_IMPLICIT_COMPILE_PROC_TIME - A.TOTAL_IMPLICIT_COMPILE_PROC_TIME AS TOTAL_IMPLICIT_COMPILE_PROC_TIME, B.TOTAL_COMMIT_PROC_TIME - A.TOTAL_COMMIT_PROC_TIME AS TOTAL_COMMIT_PROC_TIME, B.TOTAL_ROLLBACK_PROC_TIME - A.TOTAL_ROLLBACK_PROC_TIME AS TOTAL_ROLLBACK_PROC_TIME, B.TOTAL_RUNSTATS_PROC_TIME - A.TOTAL_RUNSTATS_PROC_TIME AS TOTAL_RUNSTATS_PROC_TIME, B.TOTAL_REORG_PROC_TIME - A.TOTAL_REORG_PROC_TIME AS TOTAL_REORG_PROC_TIME, B.TOTAL_LOAD_PROC_TIME - A.TOTAL_LOAD_PROC_TIME AS TOTAL_LOAD_PROC_TIME, B.TOTAL_APP_COMMITS - A.TOTAL_APP_COMMITS AS TOTAL_APP_COMMITS, B.TOTAL_ROUTINE_INVOCATIONS - A.TOTAL_ROUTINE_INVOCATIONS AS TOTAL_ROUTINE_INVOCATIONS, B.TOTAL_ROUTINE_TIME - A.TOTAL_ROUTINE_TIME AS TOTAL_ROUTINE_TIME, B.TOTAL_COMPILATIONS - A.TOTAL_COMPILATIONS AS TOTAL_COMPILATIONS, B.PKG_CACHE_INSERTS - A.PKG_CACHE_INSERTS AS PKG_CACHE_INSERTS, B.PKG_CACHE_LOOKUPS - A.PKG_CACHE_LOOKUPS AS PKG_CACHE_LOOKUPS, B.CAT_CACHE_INSERTS - A.CAT_CACHE_INSERTS AS CAT_CACHE_INSERTS, B.CAT_CACHE_LOOKUPS - A.CAT_CACHE_LOOKUPS AS CAT_CACHE_LOOKUPS, B.INT_COMMITS - A.INT_COMMITS AS INT_COMMITS, B.TOTAL_APP_ROLLBACKS - A.TOTAL_APP_ROLLBACKS AS TOTAL_APP_ROLLBACKS, B.INT_ROLLBACKS - A.INT_ROLLBACKS AS INT_ROLLBACKS, B.TOTAL_RUNSTATS - A.TOTAL_RUNSTATS AS TOTAL_RUNSTATS, B.TOTAL_REORGS - A.TOTAL_REORGS AS TOTAL_REORGS, B.TOTAL_LOADS - A.TOTAL_LOADS AS TOTAL_LOADS /* B (below) collects the metrics again (at the end of the interval) */ FROM (SELECT APPLICATION_HANDLE, SUM(WLM_QUEUE_TIME_TOTAL) AS WLM_QUEUE_TIME_TOTAL, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(TCPIP_RECVS_TOTAL) AS TCPIP_RECVS_TOTAL, SUM(TCPIP_SENDS_TOTAL) AS TCPIP_SENDS_TOTAL, SUM(IPC_RECVS_TOTAL) AS IPC_RECVS_TOTAL, SUM(IPC_SENDS_TOTAL) AS IPC_SENDS_TOTAL, SUM(TCPIP_SEND_WAIT_TIME) AS TCPIP_SEND_WAIT_TIME, SUM(TCPIP_RECV_WAIT_TIME) AS TCPIP_RECV_WAIT_TIME, SUM(IPC_SEND_WAIT_TIME) AS IPC_SEND_WAIT_TIME, SUM(IPC_RECV_WAIT_TIME) AS IPC_RECV_WAIT_TIME, SUM(TCPIP_RECV_VOLUME) AS TCPIP_RECV_VOLUME, SUM(IPC_RECV_VOLUME) AS IPC_RECV_VOLUME, SUM(TCPIP_SEND_VOLUME) AS TCPIP_SEND_VOLUME, SUM(IPC_SEND_VOLUME) AS IPC_SEND_VOLUME, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_ABORTED_TOTAL) AS ACT_ABORTED_TOTAL, SUM(ACT_REJECTED_TOTAL) AS ACT_REJECTED_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(POOL_DATA_L_READS) AS POOL_DATA_L_READS, SUM(POOL_INDEX_L_READS) AS POOL_INDEX_L_READS, SUM(POOL_TEMP_DATA_L_READS) AS POOL_TEMP_DATA_L_READS, SUM(POOL_TEMP_INDEX_L_READS) AS POOL_TEMP_INDEX_L_READS, SUM(POOL_TEMP_XDA_L_READS) AS POOL_TEMP_XDA_L_READS, SUM(POOL_XDA_L_READS) AS POOL_XDA_L_READS, SUM(POOL_DATA_P_READS) AS POOL_DATA_P_READS, SUM(POOL_INDEX_P_READS) AS POOL_INDEX_P_READS, SUM(POOL_TEMP_DATA_P_READS) AS POOL_TEMP_DATA_P_READS, SUM(POOL_TEMP_INDEX_P_READS) AS POOL_TEMP_INDEX_P_READS, SUM(POOL_TEMP_XDA_P_READS) AS POOL_TEMP_XDA_P_READS, SUM(POOL_XDA_P_READS) AS POOL_XDA_P_READS, SUM(POOL_READ_TIME) AS POOL_READ_TIME, SUM(POOL_WRITE_TIME) AS POOL_WRITE_TIME, SUM(POOL_DATA_WRITES) AS POOL_DATA_WRITES, SUM(POOL_INDEX_WRITES) AS POOL_INDEX_WRITES, SUM(POOL_XDA_WRITES) AS POOL_XDA_WRITES, SUM(DIRECT_READ_TIME) AS DIRECT_READ_TIME, SUM(DIRECT_READS) AS DIRECT_READS, SUM(DIRECT_READ_REQS) AS DIRECT_READ_REQS, SUM(DIRECT_WRITE_TIME) AS DIRECT_WRITE_TIME, SUM(DIRECT_WRITES) AS DIRECT_WRITES, SUM(DIRECT_WRITE_REQS) AS DIRECT_WRITE_REQS, SUM(LOG_DISK_WAIT_TIME) AS LOG_DISK_WAIT_TIME, SUM(LOG_DISK_WAITS_TOTAL) AS LOG_DISK_WAITS_TOTAL, SUM(NUM_LOG_BUFFER_FULL) AS NUM_LOG_BUFFER_FULL, SUM(CLIENT_IDLE_WAIT_TIME) AS CLIENT_IDLE_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(FCM_SEND_WAIT_TIME) AS FCM_SEND_WAIT_TIME, SUM(TOTAL_SORTS) AS TOTAL_SORTS, SUM(SORT_OVERFLOWS) AS SORT_OVERFLOWS, SUM(POST_THRESHOLD_SORTS) AS POST_THRESHOLD_SORTS, SUM(POST_SHRTHRESHOLD_SORTS) AS POST_SHRTHRESHOLD_SORTS, SUM(FCM_SEND_VOLUME) AS FCM_SEND_VOLUME, SUM(FCM_SENDS_TOTAL) AS FCM_SENDS_TOTAL, SUM(FCM_RECV_VOLUME) AS FCM_RECV_VOLUME, SUM(FCM_RECVS_TOTAL) AS FCM_RECVS_TOTAL, SUM(WLM_QUEUE_ASSIGNMENTS_TOTAL) AS WLM_QUEUE_ASSIGNMENTS_TOTAL, SUM(FCM_RECV_WAIT_TIME) AS FCM_RECV_WAIT_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS TOTAL_SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS TOTAL_SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME) AS TOTAL_COMPILE_PROC_TIME, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS TOTAL_IMPLICIT_COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME) AS TOTAL_COMMIT_PROC_TIME, SUM(TOTAL_ROLLBACK_PROC_TIME) AS TOTAL_ROLLBACK_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME) AS TOTAL_RUNSTATS_PROC_TIME, SUM(TOTAL_REORG_PROC_TIME) AS TOTAL_REORG_PROC_TIME, SUM(TOTAL_LOAD_PROC_TIME) AS TOTAL_LOAD_PROC_TIME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_ROUTINE_INVOCATIONS) AS TOTAL_ROUTINE_INVOCATIONS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME, SUM(TOTAL_COMPILATIONS) AS TOTAL_COMPILATIONS, SUM(PKG_CACHE_INSERTS) AS PKG_CACHE_INSERTS, SUM(PKG_CACHE_LOOKUPS) AS PKG_CACHE_LOOKUPS, SUM(CAT_CACHE_INSERTS) AS CAT_CACHE_INSERTS, SUM(CAT_CACHE_LOOKUPS) AS CAT_CACHE_LOOKUPS, SUM(INT_COMMITS) AS INT_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(INT_ROLLBACKS) AS INT_ROLLBACKS, SUM(TOTAL_RUNSTATS) AS TOTAL_RUNSTATS, SUM(TOTAL_REORGS) AS TOTAL_REORGS, SUM(TOTAL_LOADS) AS TOTAL_LOADS FROM TABLE(MON_GET_CONNECTION(APP_HANDLE, DBMEMBER)) GROUP BY APPLICATION_HANDLE ) AS B, /* A (below) has the metrics collected at the beginning of interval */ UNNEST (APPLICATION_HANDLE_ARRAY, APPLICATION_NAME_ARRAY, APPLICATION_ID_ARRAY, SYSTEM_AUTH_ID_ARRAY, SESSION_AUTH_ID_ARRAY, CLIENT_ACCTNG_ARRAY, CLIENT_USERID_ARRAY, CLIENT_APPLNAME_ARRAY, CLIENT_WRKSTNNAME_ARRAY, CLIENT_PID_ARRAY, CLIENT_PRDID_ARRAY, CLIENT_PLATFORM_ARRAY, CLIENT_PROTOCOL_ARRAY, CONNECTION_START_TIME_ARRAY, NUM_LOCKS_HELD_ARRAY, WLM_QUEUE_TIME_TOTAL_ARRAY, AGENT_WAIT_TIME_ARRAY, TCPIP_RECVS_TOTAL_ARRAY, TCPIP_SENDS_TOTAL_ARRAY, IPC_RECVS_TOTAL_ARRAY, IPC_SENDS_TOTAL_ARRAY, TCPIP_SEND_WAIT_TIME_ARRAY, TCPIP_RECV_WAIT_TIME_ARRAY, IPC_SEND_WAIT_TIME_ARRAY, IPC_RECV_WAIT_TIME_ARRAY, TCPIP_RECV_VOLUME_ARRAY, IPC_RECV_VOLUME_ARRAY, TCPIP_SEND_VOLUME_ARRAY, IPC_SEND_VOLUME_ARRAY, LOCK_ESCALS_ARRAY, LOCK_WAITS_ARRAY, LOCK_TIMEOUTS_ARRAY, DEADLOCKS_ARRAY, ACT_COMPLETED_TOTAL_ARRAY, ACT_ABORTED_TOTAL_ARRAY, ACT_REJECTED_TOTAL_ARRAY, APP_RQSTS_COMPLETED_TOTAL_ARRAY, TOTAL_RQST_TIME_ARRAY, TOTAL_CPU_TIME_ARRAY, TOTAL_WAIT_TIME_ARRAY, TOTAL_ACT_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, ROWS_READ_ARRAY, ROWS_RETURNED_ARRAY, ROWS_MODIFIED_ARRAY, POOL_DATA_L_READS_ARRAY, POOL_INDEX_L_READS_ARRAY, POOL_TEMP_DATA_L_READS_ARRAY, POOL_TEMP_INDEX_L_READS_ARRAY, POOL_TEMP_XDA_L_READS_ARRAY, POOL_XDA_L_READS_ARRAY, POOL_DATA_P_READS_ARRAY, POOL_INDEX_P_READS_ARRAY, POOL_TEMP_DATA_P_READS_ARRAY, POOL_TEMP_INDEX_P_READS_ARRAY, POOL_TEMP_XDA_P_READS_ARRAY, POOL_XDA_P_READS_ARRAY, POOL_READ_TIME_ARRAY, POOL_WRITE_TIME_ARRAY, POOL_DATA_WRITES_ARRAY, POOL_INDEX_WRITES_ARRAY, POOL_XDA_WRITES_ARRAY, DIRECT_READ_TIME_ARRAY, DIRECT_READS_ARRAY, DIRECT_READ_REQS_ARRAY, DIRECT_WRITE_TIME_ARRAY, DIRECT_WRITES_ARRAY, DIRECT_WRITE_REQS_ARRAY, LOG_DISK_WAIT_TIME_ARRAY, LOG_DISK_WAITS_TOTAL_ARRAY, NUM_LOG_BUFFER_FULL_ARRAY, CLIENT_IDLE_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, FCM_SEND_WAIT_TIME_ARRAY, TOTAL_SORTS_ARRAY, SORT_OVERFLOWS_ARRAY, POST_THRESHOLD_SORTS_ARRAY, POST_SHRTHRESHOLD_SORTS_ARRAY, FCM_SEND_VOLUME_ARRAY, FCM_SENDS_TOTAL_ARRAY, FCM_RECV_VOLUME_ARRAY, FCM_RECVS_TOTAL_ARRAY, WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY, FCM_RECV_WAIT_TIME_ARRAY, TOTAL_SECTION_PROC_TIME_ARRAY, TOTAL_SECTION_SORT_PROC_TIME_ARRAY, TOTAL_COMPILE_PROC_TIME_ARRAY, TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY, TOTAL_COMMIT_PROC_TIME_ARRAY, TOTAL_ROLLBACK_PROC_TIME_ARRAY, TOTAL_RUNSTATS_PROC_TIME_ARRAY, TOTAL_REORG_PROC_TIME_ARRAY, TOTAL_LOAD_PROC_TIME_ARRAY, TOTAL_APP_COMMITS_ARRAY, TOTAL_ROUTINE_INVOCATIONS_ARRAY, TOTAL_ROUTINE_TIME_ARRAY, TOTAL_COMPILATIONS_ARRAY, PKG_CACHE_INSERTS_ARRAY, PKG_CACHE_LOOKUPS_ARRAY, CAT_CACHE_INSERTS_ARRAY, CAT_CACHE_LOOKUPS_ARRAY, INT_COMMITS_ARRAY, TOTAL_APP_ROLLBACKS_ARRAY, INT_ROLLBACKS_ARRAY, TOTAL_RUNSTATS_ARRAY, TOTAL_REORGS_ARRAY, TOTAL_LOADS_ARRAY ) AS A (APPLICATION_HANDLE, APPLICATION_NAME, APPLICATION_ID, SYSTEM_AUTH_ID, SESSION_AUTH_ID, CLIENT_ACCTNG, CLIENT_USERID, CLIENT_APPLNAME, CLIENT_WRKSTNNAME, CLIENT_PID, CLIENT_PRDID, CLIENT_PLATFORM, CLIENT_PROTOCOL, CONNECTION_START_TIME, NUM_LOCKS_HELD, WLM_QUEUE_TIME_TOTAL, AGENT_WAIT_TIME, TCPIP_RECVS_TOTAL, TCPIP_SENDS_TOTAL, IPC_RECVS_TOTAL, IPC_SENDS_TOTAL, TCPIP_SEND_WAIT_TIME, TCPIP_RECV_WAIT_TIME, IPC_SEND_WAIT_TIME, IPC_RECV_WAIT_TIME, TCPIP_RECV_VOLUME, IPC_RECV_VOLUME, TCPIP_SEND_VOLUME, IPC_SEND_VOLUME, LOCK_ESCALS, LOCK_WAITS, LOCK_TIMEOUTS, DEADLOCKS, ACT_COMPLETED_TOTAL, ACT_ABORTED_TOTAL, ACT_REJECTED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_CPU_TIME, TOTAL_WAIT_TIME, TOTAL_ACT_TIME, TOTAL_ACT_WAIT_TIME, ROWS_READ, ROWS_RETURNED, ROWS_MODIFIED, POOL_DATA_L_READS, POOL_INDEX_L_READS, POOL_TEMP_DATA_L_READS, POOL_TEMP_INDEX_L_READS, POOL_TEMP_XDA_L_READS, POOL_XDA_L_READS, POOL_DATA_P_READS, POOL_INDEX_P_READS, POOL_TEMP_DATA_P_READS, POOL_TEMP_INDEX_P_READS, POOL_TEMP_XDA_P_READS, POOL_XDA_P_READS, POOL_READ_TIME, POOL_WRITE_TIME, POOL_DATA_WRITES, POOL_INDEX_WRITES, POOL_XDA_WRITES, DIRECT_READ_TIME, DIRECT_READS, DIRECT_READ_REQS, DIRECT_WRITE_TIME, DIRECT_WRITES, DIRECT_WRITE_REQS, LOG_DISK_WAIT_TIME, LOG_DISK_WAITS_TOTAL, NUM_LOG_BUFFER_FULL, CLIENT_IDLE_WAIT_TIME, LOCK_WAIT_TIME, FCM_SEND_WAIT_TIME, TOTAL_SORTS, SORT_OVERFLOWS, POST_THRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS, FCM_SEND_VOLUME, FCM_SENDS_TOTAL, FCM_RECV_VOLUME, FCM_RECVS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL, FCM_RECV_WAIT_TIME, TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME, TOTAL_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_COMMIT_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME, TOTAL_REORG_PROC_TIME, TOTAL_LOAD_PROC_TIME, TOTAL_APP_COMMITS, TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_TIME, TOTAL_COMPILATIONS, PKG_CACHE_INSERTS, PKG_CACHE_LOOKUPS, CAT_CACHE_INSERTS, CAT_CACHE_LOOKUPS, INT_COMMITS, TOTAL_APP_ROLLBACKS, INT_ROLLBACKS, TOTAL_RUNSTATS, TOTAL_REORGS, TOTAL_LOADS) WHERE A.APPLICATION_HANDLE = B.APPLICATION_HANDLE ORDER BY A.APPLICATION_HANDLE ); END IF; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	PROCEDURE  INITMSGCACHE ( INOUT CACHEARRAY REPORT_TYPE, IN ARRAYINDEX INTEGER, IN MSGINDEX INTEGER, IN NUMMSGS INTEGER, IN LOC VARCHAR(33)) SPECIFIC MONREPORT_INITMSGCACHE LANGUAGE SQL BEGIN DECLARE MSGCOUNT INTEGER DEFAULT 0; DECLARE RCODE INTEGER; DECLARE CCODE INTEGER DEFAULT 1208; DECLARE MSG VARCHAR(80); WHILE (MSGCOUNT < NUMMSGS) DO CALL SYSIBM.SQLCAMESSAGECCSID (MSGINDEX, 80, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'db2monreport.mo', LOC, MSG, RCODE, CCODE); SET CACHEARRAY[ARRAYINDEX] = MSG; SET MSGINDEX   = MSGINDEX + 1; SET ARRAYINDEX = ARRAYINDEX + 1; SET MSGCOUNT   = MSGCOUNT + 1; END WHILE; END;

ALTER MODULE "SYSIBMADM"."MONREPORT" ADD
	PROCEDURE  SAVE_EXEC_INFO (  IN EXEC_ID VARCHAR(32) FOR BIT DATA, IN STMT_TEXT VARCHAR(80), INOUT EXEC_ID_ARRAY MONEXEC_TYPE, INOUT EXEC_STMT_ARRAY MONMETRICS_CHAR80_TYPE, INOUT LAST_EXEC_NUM INTEGER, OUT EXEC_NUM INTEGER) SPECIFIC MONREPORT_SAVE_EXEC_INFO LANGUAGE SQL BEGIN SET EXEC_NUM = 1; WHILE (EXEC_NUM <= LAST_EXEC_NUM) AND (EXEC_ID_ARRAY[EXEC_NUM] <> EXEC_ID) DO SET EXEC_NUM = EXEC_NUM + 1; END WHILE; IF EXEC_NUM > LAST_EXEC_NUM THEN SET EXEC_ID_ARRAY[EXEC_NUM] = EXEC_ID; VALUES SYSIBM.REPLACE(STMT_TEXT,X'0A',' ') INTO STMT_TEXT; VALUES SYSIBM.REPLACE(STMT_TEXT,X'0D',' ') INTO STMT_TEXT; VALUES SYSIBM.REPLACE(STMT_TEXT,X'09',' ') INTO STMT_TEXT; SET EXEC_STMT_ARRAY[EXEC_NUM] = STMT_TEXT; SET LAST_EXEC_NUM = EXEC_NUM; END IF; RETURN EXEC_NUM; END;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  CONNECTION ( IN TIMEINTERVAL INTEGER DEFAULT 10, IN APPLICATION_HANDLE BIGINT DEFAULT NULL) SPECIFIC MONREPORT_CONNECTION LANGUAGE SQL DYNAMIC RESULT SETS 1 BEGIN DECLARE LOC VARCHAR(33); DECLARE REPOUTPUT, MSGCACHE, CR_MSGCACHE REPORT_TYPE; DECLARE TODAY, DBNAME VARCHAR(56); DECLARE I, L, IR, LAST_IR, IC, CR_IC, START_DETAILS, MSGCOUNT, MSGINDEX INTEGER; DECLARE CALCVALUE DOUBLE; DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE CLIENT_ACCTNG_ARRAY, CLIENT_USERID_ARRAY, CLIENT_APPLNAME_ARRAY, CLIENT_WRKSTNNAME_ARRAY MONMETRICS_CHAR255_TYPE; DECLARE APPLICATION_NAME_ARRAY, APPLICATION_ID_ARRAY, SYSTEM_AUTH_ID_ARRAY, SESSION_AUTH_ID_ARRAY, CLIENT_PRDID_ARRAY MONMETRICS_CHAR128_TYPE; DECLARE CLIENT_PLATFORM_ARRAY MONMETRICS_CHAR12_TYPE; DECLARE CLIENT_PROTOCOL_ARRAY MONMETRICS_CHAR10_TYPE; DECLARE CONNECTION_START_TIME_ARRAY MONMETRICS_TIMESTAMP_TYPE; DECLARE APPLICATION_HANDLE_ARRAY, CLIENT_PID_ARRAY, NUM_LOCKS_HELD_ARRAY, WLM_QUEUE_TIME_TOTAL_ARRAY, AGENT_WAIT_TIME_ARRAY, TCPIP_RECVS_TOTAL_ARRAY, TCPIP_SENDS_TOTAL_ARRAY, IPC_RECVS_TOTAL_ARRAY, IPC_SENDS_TOTAL_ARRAY, TCPIP_SEND_WAIT_TIME_ARRAY, TCPIP_RECV_WAIT_TIME_ARRAY, IPC_SEND_WAIT_TIME_ARRAY, IPC_RECV_WAIT_TIME_ARRAY, TCPIP_RECV_VOLUME_ARRAY, IPC_RECV_VOLUME_ARRAY, TCPIP_SEND_VOLUME_ARRAY, IPC_SEND_VOLUME_ARRAY, LOCK_ESCALS_ARRAY, LOCK_WAITS_ARRAY, LOCK_TIMEOUTS_ARRAY, DEADLOCKS_ARRAY, ACT_COMPLETED_TOTAL_ARRAY, ACT_ABORTED_TOTAL_ARRAY, ACT_REJECTED_TOTAL_ARRAY, APP_RQSTS_COMPLETED_TOTAL_ARRAY, TOTAL_RQST_TIME_ARRAY, TOTAL_CPU_TIME_ARRAY, TOTAL_WAIT_TIME_ARRAY, TOTAL_ACT_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, ROWS_READ_ARRAY, ROWS_RETURNED_ARRAY, ROWS_MODIFIED_ARRAY, POOL_DATA_L_READS_ARRAY, POOL_INDEX_L_READS_ARRAY, POOL_TEMP_DATA_L_READS_ARRAY, POOL_TEMP_INDEX_L_READS_ARRAY, POOL_TEMP_XDA_L_READS_ARRAY, POOL_XDA_L_READS_ARRAY, POOL_DATA_P_READS_ARRAY, POOL_INDEX_P_READS_ARRAY, POOL_TEMP_DATA_P_READS_ARRAY, POOL_TEMP_INDEX_P_READS_ARRAY, POOL_TEMP_XDA_P_READS_ARRAY, POOL_XDA_P_READS_ARRAY, POOL_READ_TIME_ARRAY, POOL_WRITE_TIME_ARRAY, POOL_DATA_WRITES_ARRAY, POOL_INDEX_WRITES_ARRAY, POOL_XDA_WRITES_ARRAY, DIRECT_READ_TIME_ARRAY, DIRECT_READS_ARRAY, DIRECT_READ_REQS_ARRAY, DIRECT_WRITE_TIME_ARRAY, DIRECT_WRITES_ARRAY, DIRECT_WRITE_REQS_ARRAY, LOG_DISK_WAIT_TIME_ARRAY, LOG_DISK_WAITS_TOTAL_ARRAY, NUM_LOG_BUFFER_FULL_ARRAY, CLIENT_IDLE_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, FCM_SEND_WAIT_TIME_ARRAY, TOTAL_SORTS_ARRAY, SORT_OVERFLOWS_ARRAY, POST_THRESHOLD_SORTS_ARRAY, POST_SHRTHRESHOLD_SORTS_ARRAY, FCM_SEND_VOLUME_ARRAY, FCM_SENDS_TOTAL_ARRAY, FCM_RECV_VOLUME_ARRAY, FCM_RECVS_TOTAL_ARRAY, WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY, FCM_RECV_WAIT_TIME_ARRAY, TOTAL_SECTION_PROC_TIME_ARRAY, TOTAL_SECTION_SORT_PROC_TIME_ARRAY, TOTAL_COMPILE_PROC_TIME_ARRAY, TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY, TOTAL_COMMIT_PROC_TIME_ARRAY, TOTAL_ROLLBACK_PROC_TIME_ARRAY, TOTAL_RUNSTATS_PROC_TIME_ARRAY, TOTAL_REORG_PROC_TIME_ARRAY, TOTAL_LOAD_PROC_TIME_ARRAY, TOTAL_APP_COMMITS_ARRAY, TOTAL_ROUTINE_INVOCATIONS_ARRAY, TOTAL_ROUTINE_TIME_ARRAY, TOTAL_COMPILATIONS_ARRAY, PKG_CACHE_INSERTS_ARRAY, PKG_CACHE_LOOKUPS_ARRAY, CAT_CACHE_INSERTS_ARRAY, CAT_CACHE_LOOKUPS_ARRAY, INT_COMMITS_ARRAY, TOTAL_APP_ROLLBACKS_ARRAY, INT_ROLLBACKS_ARRAY, TOTAL_RUNSTATS_ARRAY, TOTAL_REORGS_ARRAY, TOTAL_LOADS_ARRAY MONMETRICS_BIGINT_TYPE; /* this cursor is used to return the report as a result set */ DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); /* check input argument */ IF (TIMEINTERVAL IS NULL) THEN SET TIMEINTERVAL = 10; ELSEIF ((TIMEINTERVAL < 0) OR (TIMEINTERVAL > 3600)) THEN CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'CONNECTION', 'TIMEINTERVAL' ); END IF; /* collect the delta values */ CALL CONNDELTAS (TIMEINTERVAL, APPLICATION_HANDLE, -2, APPLICATION_HANDLE_ARRAY, APPLICATION_NAME_ARRAY, APPLICATION_ID_ARRAY, SYSTEM_AUTH_ID_ARRAY, SESSION_AUTH_ID_ARRAY, CLIENT_ACCTNG_ARRAY, CLIENT_USERID_ARRAY, CLIENT_APPLNAME_ARRAY, CLIENT_WRKSTNNAME_ARRAY, CLIENT_PID_ARRAY, CLIENT_PRDID_ARRAY, CLIENT_PLATFORM_ARRAY, CLIENT_PROTOCOL_ARRAY, CONNECTION_START_TIME_ARRAY, NUM_LOCKS_HELD_ARRAY, WLM_QUEUE_TIME_TOTAL_ARRAY, AGENT_WAIT_TIME_ARRAY, TCPIP_RECVS_TOTAL_ARRAY, TCPIP_SENDS_TOTAL_ARRAY, IPC_RECVS_TOTAL_ARRAY, IPC_SENDS_TOTAL_ARRAY, TCPIP_SEND_WAIT_TIME_ARRAY, TCPIP_RECV_WAIT_TIME_ARRAY, IPC_SEND_WAIT_TIME_ARRAY, IPC_RECV_WAIT_TIME_ARRAY, TCPIP_RECV_VOLUME_ARRAY, IPC_RECV_VOLUME_ARRAY, TCPIP_SEND_VOLUME_ARRAY, IPC_SEND_VOLUME_ARRAY, LOCK_ESCALS_ARRAY, LOCK_WAITS_ARRAY, LOCK_TIMEOUTS_ARRAY, DEADLOCKS_ARRAY, ACT_COMPLETED_TOTAL_ARRAY, ACT_ABORTED_TOTAL_ARRAY, ACT_REJECTED_TOTAL_ARRAY, APP_RQSTS_COMPLETED_TOTAL_ARRAY, TOTAL_RQST_TIME_ARRAY, TOTAL_CPU_TIME_ARRAY, TOTAL_WAIT_TIME_ARRAY, TOTAL_ACT_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, ROWS_READ_ARRAY, ROWS_RETURNED_ARRAY, ROWS_MODIFIED_ARRAY, POOL_DATA_L_READS_ARRAY, POOL_INDEX_L_READS_ARRAY, POOL_TEMP_DATA_L_READS_ARRAY, POOL_TEMP_INDEX_L_READS_ARRAY, POOL_TEMP_XDA_L_READS_ARRAY, POOL_XDA_L_READS_ARRAY, POOL_DATA_P_READS_ARRAY, POOL_INDEX_P_READS_ARRAY, POOL_TEMP_DATA_P_READS_ARRAY, POOL_TEMP_INDEX_P_READS_ARRAY, POOL_TEMP_XDA_P_READS_ARRAY, POOL_XDA_P_READS_ARRAY, POOL_READ_TIME_ARRAY, POOL_WRITE_TIME_ARRAY, POOL_DATA_WRITES_ARRAY, POOL_INDEX_WRITES_ARRAY, POOL_XDA_WRITES_ARRAY, DIRECT_READ_TIME_ARRAY, DIRECT_READS_ARRAY, DIRECT_READ_REQS_ARRAY, DIRECT_WRITE_TIME_ARRAY, DIRECT_WRITES_ARRAY, DIRECT_WRITE_REQS_ARRAY, LOG_DISK_WAIT_TIME_ARRAY, LOG_DISK_WAITS_TOTAL_ARRAY, NUM_LOG_BUFFER_FULL_ARRAY, CLIENT_IDLE_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, FCM_SEND_WAIT_TIME_ARRAY, TOTAL_SORTS_ARRAY, SORT_OVERFLOWS_ARRAY, POST_THRESHOLD_SORTS_ARRAY, POST_SHRTHRESHOLD_SORTS_ARRAY, FCM_SEND_VOLUME_ARRAY, FCM_SENDS_TOTAL_ARRAY, FCM_RECV_VOLUME_ARRAY, FCM_RECVS_TOTAL_ARRAY, WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY, FCM_RECV_WAIT_TIME_ARRAY, TOTAL_SECTION_PROC_TIME_ARRAY, TOTAL_SECTION_SORT_PROC_TIME_ARRAY, TOTAL_COMPILE_PROC_TIME_ARRAY, TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY, TOTAL_COMMIT_PROC_TIME_ARRAY, TOTAL_ROLLBACK_PROC_TIME_ARRAY, TOTAL_RUNSTATS_PROC_TIME_ARRAY, TOTAL_REORG_PROC_TIME_ARRAY, TOTAL_LOAD_PROC_TIME_ARRAY, TOTAL_APP_COMMITS_ARRAY, TOTAL_ROUTINE_INVOCATIONS_ARRAY, TOTAL_ROUTINE_TIME_ARRAY, TOTAL_COMPILATIONS_ARRAY, PKG_CACHE_INSERTS_ARRAY, PKG_CACHE_LOOKUPS_ARRAY, CAT_CACHE_INSERTS_ARRAY, CAT_CACHE_LOOKUPS_ARRAY, INT_COMMITS_ARRAY, TOTAL_APP_ROLLBACKS_ARRAY, INT_ROLLBACKS_ARRAY, TOTAL_RUNSTATS_ARRAY, TOTAL_REORGS_ARRAY, TOTAL_LOADS_ARRAY); /* fetch and cache all localized text for building report output */ VALUES (12768, 45, 1, 1) INTO MSGINDEX, MSGCOUNT, IC, IR; CALL INITMSGCACHE(MSGCACHE,IC,MSGINDEX,MSGCOUNT,LOC); VALUES (12491, 171, 1) INTO MSGINDEX, MSGCOUNT, CR_IC; CALL INITMSGCACHE(CR_MSGCACHE,CR_IC,MSGINDEX,MSGCOUNT,LOC); /* IR is the index in the report output array */ /* IC is the index in the message cache array */ /* =============================== */ /* start of report output - header */ /* =============================== */ VALUES (CURRENT SERVER) INTO DBNAME; SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(DBNAME,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(TODAY,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TIMEINTERVAL),''); VALUES (IR+1, IC+1) INTO IR, IC; IF (APPLICATION_HANDLE IS NULL) THEN SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; ELSE SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(APPLICATION_HANDLE),''); VALUES (IR+1, IC+1) INTO IR, IC; END IF; /* =============================== */ /* Part 1 - Summary of connections */ /* =============================== */ SET LAST_IR = IR + 7; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(APPLICATION_HANDLE_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(I),3) || SPACE(2) || RPAD(VARCHAR(APPLICATION_HANDLE_ARRAY[I]),11,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_CPU_TIME_ARRAY[I]),12,' ') || SPACE(2)|| RPAD(VARCHAR(TOTAL_ACT_TIME_ARRAY[I]),8,' ') || SPACE(2)|| RPAD(VARCHAR(ACT_COMPLETED_TOTAL_ARRAY[I]),13,' ') ||SPACE(2) || RPAD(VARCHAR(TOTAL_WAIT_TIME_ARRAY[I]),10,' ') || SPACE(2) || RPAD(VARCHAR(CLIENT_IDLE_WAIT_TIME_ARRAY[I]),10,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* =================================== */ /* Par 2 - Details for each connection */ /* =================================== */ SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (1, CARDINALITY(APPLICATION_HANDLE_ARRAY), IC) INTO I, L, START_DETAILS; WHILE (I <= L) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(I),''); VALUES (IR+1, IC+1) INTO IR, IC; SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(APPLICATION_HANDLE_ARRAY[I]),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(APPLICATION_NAME_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(APPLICATION_ID_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(SYSTEM_AUTH_ID_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(SESSION_AUTH_ID_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(CLIENT_ACCTNG_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(CLIENT_USERID_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(CLIENT_APPLNAME_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(CLIENT_WRKSTNNAME_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CLIENT_PID_ARRAY[I]),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(SUBSTR(CLIENT_PRDID_ARRAY[I],1,42),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CLIENT_PLATFORM_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CLIENT_PROTOCOL_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CONNECTION_START_TIME_ARRAY[I]),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(NUM_LOCKS_HELD_ARRAY[I]),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; CALL COMMONREQMETRICS (REPOUTPUT, IR, CR_MSGCACHE, TIMEINTERVAL, WLM_QUEUE_TIME_TOTAL_ARRAY[I], AGENT_WAIT_TIME_ARRAY[I], TCPIP_RECVS_TOTAL_ARRAY[I], TCPIP_SENDS_TOTAL_ARRAY[I], IPC_RECVS_TOTAL_ARRAY[I], IPC_SENDS_TOTAL_ARRAY[I], TCPIP_SEND_WAIT_TIME_ARRAY[I], TCPIP_RECV_WAIT_TIME_ARRAY[I], IPC_SEND_WAIT_TIME_ARRAY[I], IPC_RECV_WAIT_TIME_ARRAY[I], TCPIP_RECV_VOLUME_ARRAY[I], IPC_RECV_VOLUME_ARRAY[I], TCPIP_SEND_VOLUME_ARRAY[I], IPC_SEND_VOLUME_ARRAY[I], LOCK_ESCALS_ARRAY[I], LOCK_WAITS_ARRAY[I], LOCK_TIMEOUTS_ARRAY[I], DEADLOCKS_ARRAY[I], ACT_COMPLETED_TOTAL_ARRAY[I], ACT_ABORTED_TOTAL_ARRAY[I], ACT_REJECTED_TOTAL_ARRAY[I], APP_RQSTS_COMPLETED_TOTAL_ARRAY[I], TOTAL_RQST_TIME_ARRAY[I], TOTAL_CPU_TIME_ARRAY[I], TOTAL_WAIT_TIME_ARRAY[I], TOTAL_ACT_TIME_ARRAY[I], TOTAL_ACT_WAIT_TIME_ARRAY[I], ROWS_READ_ARRAY[I], ROWS_RETURNED_ARRAY[I], ROWS_MODIFIED_ARRAY[I], POOL_DATA_L_READS_ARRAY[I], POOL_INDEX_L_READS_ARRAY[I], POOL_TEMP_DATA_L_READS_ARRAY[I], POOL_TEMP_INDEX_L_READS_ARRAY[I], POOL_TEMP_XDA_L_READS_ARRAY[I], POOL_XDA_L_READS_ARRAY[I], POOL_DATA_P_READS_ARRAY[I], POOL_INDEX_P_READS_ARRAY[I], POOL_TEMP_DATA_P_READS_ARRAY[I], POOL_TEMP_INDEX_P_READS_ARRAY[I], POOL_TEMP_XDA_P_READS_ARRAY[I], POOL_XDA_P_READS_ARRAY[I], POOL_READ_TIME_ARRAY[I], POOL_WRITE_TIME_ARRAY[I], POOL_DATA_WRITES_ARRAY[I], POOL_INDEX_WRITES_ARRAY[I], POOL_XDA_WRITES_ARRAY[I], DIRECT_READ_TIME_ARRAY[I], DIRECT_READS_ARRAY[I], DIRECT_READ_REQS_ARRAY[I], DIRECT_WRITE_TIME_ARRAY[I], DIRECT_WRITES_ARRAY[I], DIRECT_WRITE_REQS_ARRAY[I], LOG_DISK_WAIT_TIME_ARRAY[I], LOG_DISK_WAITS_TOTAL_ARRAY[I], NUM_LOG_BUFFER_FULL_ARRAY[I], CLIENT_IDLE_WAIT_TIME_ARRAY[I], LOCK_WAIT_TIME_ARRAY[I], FCM_SEND_WAIT_TIME_ARRAY[I], TOTAL_SORTS_ARRAY[I], SORT_OVERFLOWS_ARRAY[I], POST_THRESHOLD_SORTS_ARRAY[I], POST_SHRTHRESHOLD_SORTS_ARRAY[I], FCM_SEND_VOLUME_ARRAY[I], FCM_SENDS_TOTAL_ARRAY[I], FCM_RECV_VOLUME_ARRAY[I], FCM_RECVS_TOTAL_ARRAY[I], WLM_QUEUE_ASSIGNMENTS_TOTAL_ARRAY[I], FCM_RECV_WAIT_TIME_ARRAY[I], TOTAL_SECTION_PROC_TIME_ARRAY[I], TOTAL_SECTION_SORT_PROC_TIME_ARRAY[I], TOTAL_COMPILE_PROC_TIME_ARRAY[I], TOTAL_IMPLICIT_COMPILE_PROC_TIME_ARRAY[I], TOTAL_COMMIT_PROC_TIME_ARRAY[I], TOTAL_ROLLBACK_PROC_TIME_ARRAY[I], TOTAL_RUNSTATS_PROC_TIME_ARRAY[I], TOTAL_REORG_PROC_TIME_ARRAY[I], TOTAL_LOAD_PROC_TIME_ARRAY[I], TOTAL_APP_COMMITS_ARRAY[I], TOTAL_ROUTINE_INVOCATIONS_ARRAY[I], TOTAL_ROUTINE_TIME_ARRAY[I], TOTAL_COMPILATIONS_ARRAY[I], PKG_CACHE_INSERTS_ARRAY[I], PKG_CACHE_LOOKUPS_ARRAY[I], CAT_CACHE_INSERTS_ARRAY[I], CAT_CACHE_LOOKUPS_ARRAY[I], INT_COMMITS_ARRAY[I], TOTAL_APP_ROLLBACKS_ARRAY[I], INT_ROLLBACKS_ARRAY[I], TOTAL_RUNSTATS_ARRAY[I], TOTAL_REORGS_ARRAY[I], TOTAL_LOADS_ARRAY[I]); VALUES (I + 1, START_DETAILS) INTO I, IC; END WHILE; /* open cursor to return report as result set */ OPEN RES; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  CURRENTAPPS () SPECIFIC MONREPORT_CURRENTAPPS LANGUAGE SQL DYNAMIC RESULT SETS 1 BEGIN DECLARE LOC VARCHAR(33); DECLARE REPOUTPUT, MSGCACHE REPORT_TYPE; DECLARE DBNAME, TODAY VARCHAR(56); DECLARE I, J, L, IR, LAST_IR, IC, MSGCOUNT, MSGINDEX INTEGER; DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE APPLICATION_HANDLE_ARRAY, CONN_APPLICATION_HANDLE_ARRAY, AGENT_TID_ARRAY, COUNT_ARRAY MONMETRICS_BIGINT_TYPE; DECLARE UOW_ID_ARRAY, CONN_UOW_ID_ARRAY, ACTIVITY_UOW_ID_ARRAY, ACTIVITY_ID_ARRAY, CONN_ACTIVITY_ID_ARRAY MONMETRICS_INT_TYPE; DECLARE MEMBER_ARRAY, COORD_MEMBER_ARRAY, CONN_MEMBER_ARRAY MONMETRICS_SMALLINT_TYPE; DECLARE APPLICATION_ID_ARRAY, CONN_APPLICATION_ID_ARRAY, APPLICATION_NAME_ARRAY, CONN_APPLICATION_NAME_ARRAY MONMETRICS_CHAR128_TYPE; DECLARE OBJECT_TYPE_ARRAY, AGENT_TYPE_SUBTYPE MONMETRICS_CHAR80_TYPE; DECLARE DESC_ARRAY, REQUEST_TYPE_ARRAY, AGENT_TYPE_ARRAY, AGENT_SUBTYPE_ARRAY, EVENT_OBJECT_ARRAY, EVENT_TYPE_ARRAY, WORKLOAD_OCCURRENCE_STATE_ARRAY, CONN_WORKLOAD_OCCURRENCE_STATE_ARRAY, ACTIVITY_TYPE_ARRAY, CONN_ACTIVITY_TYPE_ARRAY, ACTIVITY_STATE_ARRAY, CONN_ACTIVITY_STATE_ARRAY MONMETRICS_CHAR32_TYPE; DECLARE CONN_COUNT, ACT_COUNT BIGINT; /* this cursor is used to return the report as a result set */ DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); /* fetch and cache all localized text for building report output */ VALUES (12422, 57, 1) INTO MSGINDEX, MSGCOUNT, IC; CALL INITMSGCACHE(MSGCACHE,IC,MSGINDEX,MSGCOUNT,LOC); /* ======================================= */ /* get info about all current applications */ /* ======================================= */ SELECT ARRAY_AGG(CON.APPLICATION_HANDLE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(CON.APPLICATION_NAME ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(CON.MEMBER ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(CON.COORD_MEMBER ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(UOW.UOW_ID ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(UOW.WORKLOAD_OCCURRENCE_STATE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(UOW.APPLICATION_ID ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(ACT.ACTIVITY_ID ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(ACT.ACTIVITY_TYPE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(ACT.ACTIVITY_STATE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(ACT.UOW_ID ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.AGENT_TID ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.AGENT_TYPE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.AGENT_SUBTYPE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.REQUEST_TYPE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.EVENT_OBJECT ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC), ARRAY_AGG(SCA.EVENT_TYPE ORDER BY CON.APPLICATION_HANDLE ASC, CON.MEMBER ASC, ACT.ACTIVITY_ID ASC, SCA.AGENT_TID ASC) INTO APPLICATION_HANDLE_ARRAY, APPLICATION_NAME_ARRAY, MEMBER_ARRAY, COORD_MEMBER_ARRAY, UOW_ID_ARRAY, WORKLOAD_OCCURRENCE_STATE_ARRAY, APPLICATION_ID_ARRAY, ACTIVITY_ID_ARRAY, ACTIVITY_TYPE_ARRAY, ACTIVITY_STATE_ARRAY, ACTIVITY_UOW_ID_ARRAY, AGENT_TID_ARRAY, AGENT_TYPE_ARRAY, AGENT_SUBTYPE_ARRAY, REQUEST_TYPE_ARRAY, EVENT_OBJECT_ARRAY, EVENT_TYPE_ARRAY FROM TABLE(MON_GET_CONNECTION(NULL, -2)) AS CON JOIN TABLE(MON_GET_UNIT_OF_WORK(NULL, -2)) AS UOW ON UOW.APPLICATION_HANDLE = CON.APPLICATION_HANDLE AND UOW.MEMBER = CON.MEMBER LEFT OUTER JOIN TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(NULL, -2)) AS ACT ON ACT.APPLICATION_HANDLE = CON.APPLICATION_HANDLE AND ACT.DBPARTITIONNUM = CON.MEMBER LEFT OUTER JOIN TABLE(WLM_GET_SERVICE_CLASS_AGENTS_V97(NULL, NULL, NULL, -2)) AS SCA ON SCA.APPLICATION_HANDLE = CON.APPLICATION_HANDLE AND SCA.DBPARTITIONNUM = CON.MEMBER AND SCA.UOW_ID = ACT.UOW_ID AND SCA.ACTIVITY_ID = ACT.ACTIVITY_ID WHERE (SCA.AGENT_STATE IS NULL OR SCA.AGENT_STATE = 'ACTIVE'); /* =============================== */ /* start of report output - header */ /* =============================== */ VALUES (CURRENT SERVER, 1, 1) INTO DBNAME, IR, IC; /* IR is the index in the report output array */ /* IC is the index in the message cache array */ SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(DBNAME,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(TODAY,''); VALUES (IR+1, IC+1) INTO IR, IC; /* ========================================== */ /* part 1 - Summary of application processing */ /* ========================================== */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT COUNT(DISTINCT APPLICATION_HANDLE) INTO CONN_COUNT FROM UNNEST(APPLICATION_HANDLE_ARRAY) AS A (APPLICATION_HANDLE); SELECT COUNT(*) INTO ACT_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID FROM UNNEST (APPLICATION_HANDLE_ARRAY, ACTIVITY_UOW_ID_ARRAY, ACTIVITY_ID_ARRAY) AS A (APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID) WHERE ACTIVITY_ID IS NOT NULL); SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CONN_COUNT),''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(ACT_COUNT),''); VALUES (IR+1, IC+1) INTO IR, IC; /* Units of work by WORKLOAD_OCCURRENCE_STATE */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(WORKLOAD_OCCURRENCE_STATE), ARRAY_AGG(STATE_COUNT) INTO DESC_ARRAY, COUNT_ARRAY FROM (SELECT WORKLOAD_OCCURRENCE_STATE, COUNT(*) AS STATE_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, UOW_ID, WORKLOAD_OCCURRENCE_STATE FROM UNNEST(APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, COORD_MEMBER_ARRAY, UOW_ID_ARRAY, WORKLOAD_OCCURRENCE_STATE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, COORD_MEMBER, UOW_ID, WORKLOAD_OCCURRENCE_STATE) WHERE MEMBER = COORD_MEMBER ) AS T1 GROUP BY WORKLOAD_OCCURRENCE_STATE ) AS T2; VALUES (1, CARDINALITY(DESC_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(DESC_ARRAY[I],36,' ') || SPACE(5) || RPAD(VARCHAR(COUNT_ARRAY[I]),39,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Active coordinator agents by REQUEST_TYPE */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(REQUEST_TYPE), ARRAY_AGG(TYPE_COUNT) INTO DESC_ARRAY, COUNT_ARRAY FROM (SELECT REQUEST_TYPE, COUNT(*) AS TYPE_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, REQUEST_TYPE FROM UNNEST(APPLICATION_HANDLE_ARRAY, AGENT_TYPE_ARRAY, REQUEST_TYPE_ARRAY) AS W (APPLICATION_HANDLE, AGENT_TYPE, REQUEST_TYPE) WHERE AGENT_TYPE = 'COORDINATOR' ) AS T1 GROUP BY REQUEST_TYPE ) AS T2; VALUES (1, CARDINALITY(DESC_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(DESC_ARRAY[I],36,' ') || SPACE(5) || RPAD(VARCHAR(COUNT_ARRAY[I]),39,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* All agents by EVENT_OBJECT:EVENT_TYPE */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(OBJECT_TYPE), ARRAY_AGG(TYPE_COUNT) INTO OBJECT_TYPE_ARRAY, COUNT_ARRAY FROM (SELECT VARCHAR(OBJECT_TYPE,80) AS OBJECT_TYPE, COUNT(*) AS TYPE_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, MEMBER, AGENT_TID, EVENT_OBJECT || ':' || EVENT_TYPE AS OBJECT_TYPE FROM UNNEST(APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, AGENT_TID_ARRAY, EVENT_OBJECT_ARRAY, EVENT_TYPE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, AGENT_TID, EVENT_OBJECT, EVENT_TYPE) WHERE AGENT_TID IS NOT NULL ) AS T1 GROUP BY OBJECT_TYPE ) AS T2; VALUES (1, CARDINALITY(OBJECT_TYPE_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(OBJECT_TYPE_ARRAY[I],36,' ') || SPACE(5) || RPAD(VARCHAR(COUNT_ARRAY[I]),39,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Activities by ACTIVITY_STATE */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(ACTIVITY_STATE), ARRAY_AGG(STATE_COUNT) INTO DESC_ARRAY, COUNT_ARRAY FROM (SELECT ACTIVITY_STATE, COUNT(*) AS STATE_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID, ACTIVITY_STATE FROM UNNEST(APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, COORD_MEMBER_ARRAY, ACTIVITY_UOW_ID_ARRAY, ACTIVITY_ID_ARRAY, ACTIVITY_STATE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, COORD_MEMBER, ACTIVITY_UOW_ID, ACTIVITY_ID, ACTIVITY_STATE) WHERE ACTIVITY_ID IS NOT NULL AND MEMBER = COORD_MEMBER ) AS T1 GROUP BY ACTIVITY_STATE ) AS T2; VALUES (1, CARDINALITY(DESC_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(DESC_ARRAY[I],36,' ') || SPACE(5) || RPAD(VARCHAR(COUNT_ARRAY[I]),39,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Activities by ACTIVITY_TYPE */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(ACTIVITY_TYPE), ARRAY_AGG(STATE_COUNT) INTO DESC_ARRAY, COUNT_ARRAY FROM (SELECT ACTIVITY_TYPE, COUNT(*) AS STATE_COUNT FROM (SELECT DISTINCT APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID, ACTIVITY_TYPE FROM UNNEST(APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, COORD_MEMBER_ARRAY, ACTIVITY_UOW_ID_ARRAY, ACTIVITY_ID_ARRAY, ACTIVITY_TYPE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, COORD_MEMBER, ACTIVITY_UOW_ID, ACTIVITY_ID, ACTIVITY_TYPE) WHERE ACTIVITY_ID IS NOT NULL AND MEMBER = COORD_MEMBER ) AS T1 GROUP BY ACTIVITY_TYPE ) AS T2; VALUES (1, CARDINALITY(DESC_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(DESC_ARRAY[I],36,' ') || SPACE(5) || RPAD(VARCHAR(COUNT_ARRAY[I]),39,' '); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* ============================== */ /* part 2 - Details by connection */ /* ============================== */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(APPLICATION_HANDLE ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APPLICATION_ID ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APPLICATION_NAME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(WORKLOAD_OCCURRENCE_STATE ORDER BY APPLICATION_HANDLE) INTO CONN_APPLICATION_HANDLE_ARRAY, CONN_APPLICATION_ID_ARRAY, CONN_APPLICATION_NAME_ARRAY, CONN_WORKLOAD_OCCURRENCE_STATE_ARRAY FROM (SELECT DISTINCT APPLICATION_HANDLE, APPLICATION_ID, APPLICATION_NAME, WORKLOAD_OCCURRENCE_STATE FROM UNNEST (APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, COORD_MEMBER_ARRAY, APPLICATION_ID_ARRAY, APPLICATION_NAME_ARRAY, WORKLOAD_OCCURRENCE_STATE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, COORD_MEMBER, APPLICATION_ID, APPLICATION_NAME, WORKLOAD_OCCURRENCE_STATE) WHERE MEMBER = COORD_MEMBER); VALUES (1, CARDINALITY(CONN_APPLICATION_HANDLE_ARRAY), IC) INTO I, L, MSGINDEX; WHILE (I <= L) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CONN_APPLICATION_HANDLE_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CONN_APPLICATION_ID_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CONN_APPLICATION_NAME_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(CONN_WORKLOAD_OCCURRENCE_STATE_ARRAY[I],''); VALUES (IR+1, IC+1) INTO IR, IC; /* Agents for this connection */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(MEMBER ORDER BY MEMBER), ARRAY_AGG(AGENT_TYPE_SUBTYPE ORDER BY MEMBER), ARRAY_AGG(REQUEST_TYPE ORDER BY MEMBER), ARRAY_AGG(OBJECT_TYPE ORDER BY MEMBER) INTO CONN_MEMBER_ARRAY, AGENT_TYPE_SUBTYPE, DESC_ARRAY, OBJECT_TYPE_ARRAY FROM (SELECT DISTINCT APPLICATION_HANDLE, MEMBER, AGENT_TID, VARCHAR(COALESCE(AGENT_TYPE,'') || ':' || COALESCE(AGENT_SUBTYPE,''),80) AS AGENT_TYPE_SUBTYPE, REQUEST_TYPE, VARCHAR(EVENT_OBJECT || ':' || EVENT_TYPE,80) AS OBJECT_TYPE FROM UNNEST(APPLICATION_HANDLE_ARRAY, MEMBER_ARRAY, AGENT_TID_ARRAY, AGENT_TYPE_ARRAY, AGENT_SUBTYPE_ARRAY, REQUEST_TYPE_ARRAY, EVENT_OBJECT_ARRAY, EVENT_TYPE_ARRAY) AS W (APPLICATION_HANDLE, MEMBER, AGENT_TID, AGENT_TYPE, AGENT_SUBTYPE, REQUEST_TYPE, EVENT_OBJECT, EVENT_TYPE) WHERE APPLICATION_HANDLE = CONN_APPLICATION_HANDLE_ARRAY[I] AND REQUEST_TYPE IS NOT NULL ) AS T1; VALUES (1) INTO J; WHILE (J <= CARDINALITY(CONN_MEMBER_ARRAY)) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(CONN_MEMBER_ARRAY[J]),6,' ') || SPACE(2) || RPAD(AGENT_TYPE_SUBTYPE[J],26,' ') || SPACE(2) || RPAD(DESC_ARRAY[J],17,' ') || SPACE(2) || RPAD(OBJECT_TYPE_ARRAY[J],25,' '); VALUES (J + 1, IR + 1) INTO J, IR; END WHILE; /* Activities for this connection */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(MEMBER ORDER BY MEMBER), ARRAY_AGG(ACTIVITY_UOW_ID ORDER BY MEMBER), ARRAY_AGG(ACTIVITY_ID ORDER BY MEMBER), ARRAY_AGG(ACTIVITY_TYPE ORDER BY MEMBER), ARRAY_AGG(ACTIVITY_STATE ORDER BY MEMBER) INTO CONN_MEMBER_ARRAY, CONN_UOW_ID_ARRAY, CONN_ACTIVITY_ID_ARRAY, CONN_ACTIVITY_TYPE_ARRAY, CONN_ACTIVITY_STATE_ARRAY FROM (SELECT DISTINCT APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID, MEMBER, ACTIVITY_TYPE, ACTIVITY_STATE FROM UNNEST(APPLICATION_HANDLE_ARRAY, ACTIVITY_UOW_ID_ARRAY, ACTIVITY_ID_ARRAY, MEMBER_ARRAY, ACTIVITY_TYPE_ARRAY, ACTIVITY_STATE_ARRAY) AS W (APPLICATION_HANDLE, ACTIVITY_UOW_ID, ACTIVITY_ID, MEMBER, ACTIVITY_TYPE, ACTIVITY_STATE) WHERE APPLICATION_HANDLE = CONN_APPLICATION_HANDLE_ARRAY[I] AND ACTIVITY_ID IS NOT NULL ) AS T1; VALUES (1) INTO J; WHILE (J <= CARDINALITY(CONN_MEMBER_ARRAY)) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(CONN_MEMBER_ARRAY[J]),19,' ') || SPACE(2) || RPAD(VARCHAR(CONN_UOW_ID_ARRAY[J]),10,' ') || SPACE(2) || RPAD(VARCHAR(CONN_ACTIVITY_ID_ARRAY[J]),14,' ') || SPACE(2) || RPAD(CONN_ACTIVITY_TYPE_ARRAY[J],14,' ') || SPACE(2) || RPAD(CONN_ACTIVITY_STATE_ARRAY[J],15,' '); VALUES (J + 1, IR + 1) INTO J, IR; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (I + 1, MSGINDEX) INTO I, IC; END WHILE; /* open cursor to return report as result set */ OPEN RES; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  CURRENTSQL ( IN MEMBER SMALLINT DEFAULT NULL) SPECIFIC MONREPORT_CURRENTSQL LANGUAGE SQL DYNAMIC RESULT SETS 1 BEGIN DECLARE LOC VARCHAR(33); DECLARE REPOUTPUT, MSGCACHE REPORT_TYPE; DECLARE DBNAME, TODAY VARCHAR(56); DECLARE ENTRY VARCHAR(40); DECLARE I, L, POS, IR, LAST_IR, IC, MSGCOUNT, MSGINDEX INTEGER; DECLARE REP_WIDTH INTEGER DEFAULT 80; DECLARE DBMEMBER SMALLINT; DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE APPLICATION_HANDLE_ARRAY, APP_ARRAY, TOTAL_CPU_TIME_ARRAY, CPU_ARRAY, ROWS_READ_ARRAY, ROWS_ARRAY, DIRECT_IO_ARRAY, IO_ARRAY, CPU_RANK_ARRAY, ROWS_RANK_ARRAY, IO_RANK_ARRAY MONMETRICS_BIGINT_TYPE; DECLARE UOW_ID_ARRAY, UOW_ARRAY, ACTIVITY_ID_ARRAY, ACT_ARRAY MONMETRICS_INT_TYPE; DECLARE STMT_TEXT_ARRAY MONMETRICS_CLOB_TYPE; DECLARE STMT_ARRAY MONMETRICS_CHAR80_TYPE; DECLARE STMT CLOB(2M); DECLARE BLOCK CLOB(32672); DECLARE BLOCK_LEN INTEGER DEFAULT 32672; DECLARE STMT_LEN INTEGER; /* this cursor is used to return the report as a result set */ DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); /* check input argument */ IF (MEMBER IS NULL) THEN VALUES (-2) INTO DBMEMBER; ELSEIF (MEMBER >= 0) THEN VALUES (MEMBER) INTO DBMEMBER; ELSE CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'CURRENTSQL', 'DBMEMBER' ); END IF; /* fetch and cache all localized text for building report output */ VALUES (13040, 44, 1) INTO MSGINDEX, MSGCOUNT, IC; CALL INITMSGCACHE(MSGCACHE,IC,MSGINDEX,MSGCOUNT,LOC); /* =============================== */ /* start of report output - header */ /* =============================== */ VALUES (CURRENT SERVER, 1, 1) INTO DBNAME, IR, IC; /* IR is the index in the report output array */ /* IC is the index in the message cache array */ SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(DBNAME,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(TODAY,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (DBMEMBER = -2) THEN SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (IC + 1) INTO IC; ELSE VALUES (IC + 1) INTO IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DBMEMBER),''); VALUES (IR+1, IC+1) INTO IR, IC; END IF; /* ============================================= */ /* get all current activities along with metrics */ /* ============================================= */ IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(A.ACTIVITY_ID ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.UOW_ID ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.APPLICATION_HANDLE ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.TOTAL_CPU_TIME ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.ROWS_READ ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.DIRECT_IO ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.CPU_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.ROWS_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.IO_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(P.STMT_TEXT ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC) INTO ACTIVITY_ID_ARRAY, UOW_ID_ARRAY, APPLICATION_HANDLE_ARRAY, TOTAL_CPU_TIME_ARRAY, ROWS_READ_ARRAY, DIRECT_IO_ARRAY, CPU_RANK_ARRAY, ROWS_RANK_ARRAY, IO_RANK_ARRAY, STMT_TEXT_ARRAY FROM TABLE(MON_GET_PKG_CACHE_STMT(NULL, NULL, NULL, DBMEMBER)) AS P, (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, EXECUTABLE_ID, MEMBER, TOTAL_CPU_TIME, ROWS_READ, DIRECT_IO, DENSE_RANK() OVER(ORDER BY TOTAL_CPU_TIME DESC) AS CPU_RANK, DENSE_RANK() OVER(ORDER BY ROWS_READ DESC) AS ROWS_RANK, DENSE_RANK() OVER(ORDER BY DIRECT_IO DESC) AS IO_RANK FROM (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, EXECUTABLE_ID, COORD_PARTITION_NUM AS MEMBER, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(DIRECT_READS + DIRECT_WRITES) AS DIRECT_IO FROM TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(NULL, DBMEMBER)) GROUP BY APPLICATION_HANDLE, UOW_ID, ACTIVITY_ID, EXECUTABLE_ID, COORD_PARTITION_NUM) ) AS A WHERE P.EXECUTABLE_ID = A.EXECUTABLE_ID AND P.MEMBER = A.MEMBER AND (A.CPU_RANK <= 10 OR A.ROWS_RANK <= 10 OR A.IO_RANK <= 10); ELSE SELECT ARRAY_AGG(A.ACTIVITY_ID ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.UOW_ID ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.APPLICATION_HANDLE ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.TOTAL_CPU_TIME ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.ROWS_READ ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.DIRECT_IO ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.CPU_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.ROWS_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(A.IO_RANK ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC), ARRAY_AGG(P.STMT_TEXT ORDER BY (A.CPU_RANK + A.ROWS_RANK + A.IO_RANK) ASC) INTO ACTIVITY_ID_ARRAY, UOW_ID_ARRAY, APPLICATION_HANDLE_ARRAY, TOTAL_CPU_TIME_ARRAY, ROWS_READ_ARRAY, DIRECT_IO_ARRAY, CPU_RANK_ARRAY, ROWS_RANK_ARRAY, IO_RANK_ARRAY, STMT_TEXT_ARRAY FROM TABLE(MON_GET_PKG_CACHE_STMT(NULL, NULL, NULL, DBMEMBER)) AS P, (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, EXECUTABLE_ID, DBPARTITIONNUM AS MEMBER, TOTAL_CPU_TIME, ROWS_READ, DIRECT_READS + DIRECT_WRITES AS DIRECT_IO, DENSE_RANK() OVER(ORDER BY TOTAL_CPU_TIME DESC) AS CPU_RANK, DENSE_RANK() OVER(ORDER BY ROWS_READ DESC) AS ROWS_RANK, DENSE_RANK() OVER(ORDER BY DIRECT_READS + DIRECT_WRITES DESC) AS IO_RANK FROM TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(NULL, DBMEMBER)) ) AS A WHERE P.EXECUTABLE_ID = A.EXECUTABLE_ID AND P.MEMBER = A.MEMBER AND (A.CPU_RANK <= 10 OR A.ROWS_RANK <= 10 OR A.IO_RANK <= 10); END IF; /* remove new lines and tabs from statement texts */ VALUES (1, CARDINALITY(STMT_TEXT_ARRAY)) INTO I, L; WHILE (I <= L) DO VALUES (1, STMT_TEXT_ARRAY[I]) INTO POS, STMT; VALUES CLOB(' ',0) INTO STMT_TEXT_ARRAY[I]; VALUES LENGTH(STMT) INTO STMT_LEN; WHILE (POS <= STMT_LEN) DO VALUES SUBSTR(STMT, POS, MIN(BLOCK_LEN, STMT_LEN - POS + 1)) INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0A', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0D', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'09', ' ') INTO BLOCK; VALUES (STMT_TEXT_ARRAY[I] || BLOCK) INTO STMT_TEXT_ARRAY[I]; VALUES (POS + BLOCK_LEN) INTO POS; END WHILE; VALUES (I + 1) INTO I; END WHILE; /* ================================= */ /* part 1 - Summaries by top metrics */ /* ================================= */ /* Top 10 current activities by TOTAL_CPU_TIME */ SET LAST_IR = IR + 8; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(ACTIVITY_ID ORDER BY TOTAL_CPU_TIME DESC), ARRAY_AGG(UOW_ID ORDER BY TOTAL_CPU_TIME DESC), ARRAY_AGG(APPLICATION_HANDLE ORDER BY TOTAL_CPU_TIME DESC), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY TOTAL_CPU_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY TOTAL_CPU_TIME DESC) INTO ACT_ARRAY, UOW_ARRAY, APP_ARRAY, CPU_ARRAY, STMT_ARRAY FROM (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, TOTAL_CPU_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM UNNEST (ACTIVITY_ID_ARRAY, UOW_ID_ARRAY, APPLICATION_HANDLE_ARRAY, TOTAL_CPU_TIME_ARRAY, STMT_TEXT_ARRAY) AS M (ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, TOTAL_CPU_TIME, STMT_TEXT) ORDER BY TOTAL_CPU_TIME DESC FETCH FIRST 10 ROWS ONLY); VALUES (1, CARDINALITY(ACT_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(ACT_ARRAY[I]),8,' ') || SPACE(2) || RPAD(VARCHAR(UOW_ARRAY[I]),6,' ') || SPACE(2)|| RPAD(VARCHAR(APP_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(CPU_ARRAY[I]),9,' ') || SPACE(2)|| RPAD(STMT_ARRAY[I],38,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* Top 10 current activities by ROWS_READ */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(ACTIVITY_ID ORDER BY ROWS_READ DESC), ARRAY_AGG(UOW_ID ORDER BY ROWS_READ DESC), ARRAY_AGG(APPLICATION_HANDLE ORDER BY ROWS_READ DESC), ARRAY_AGG(ROWS_READ ORDER BY ROWS_READ DESC), ARRAY_AGG(STMT_TEXT ORDER BY ROWS_READ DESC) INTO ACT_ARRAY, UOW_ARRAY, APP_ARRAY, ROWS_ARRAY, STMT_ARRAY FROM (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, ROWS_READ, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM UNNEST (ACTIVITY_ID_ARRAY, UOW_ID_ARRAY, APPLICATION_HANDLE_ARRAY, ROWS_READ_ARRAY, STMT_TEXT_ARRAY) AS M (ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, ROWS_READ, STMT_TEXT) ORDER BY ROWS_READ DESC FETCH FIRST 10 ROWS ONLY); VALUES (1, CARDINALITY(ACT_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(ACT_ARRAY[I]),8,' ') || SPACE(2) || RPAD(VARCHAR(UOW_ARRAY[I]),6,' ') || SPACE(2)|| RPAD(VARCHAR(APP_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(ROWS_ARRAY[I]),13,' ') || SPACE(2)|| RPAD(STMT_ARRAY[I],34,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* Top 10 current activities by DIRECT_READS + DIRECT_WRITES */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SELECT ARRAY_AGG(ACTIVITY_ID ORDER BY DIRECT_IO DESC), ARRAY_AGG(UOW_ID ORDER BY DIRECT_IO DESC), ARRAY_AGG(APPLICATION_HANDLE ORDER BY DIRECT_IO DESC), ARRAY_AGG(DIRECT_IO ORDER BY DIRECT_IO DESC), ARRAY_AGG(STMT_TEXT ORDER BY DIRECT_IO DESC) INTO ACT_ARRAY, UOW_ARRAY, APP_ARRAY, IO_ARRAY, STMT_ARRAY FROM (SELECT ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, DIRECT_IO, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM UNNEST (ACTIVITY_ID_ARRAY, UOW_ID_ARRAY, APPLICATION_HANDLE_ARRAY, DIRECT_IO_ARRAY, STMT_TEXT_ARRAY) AS M (ACTIVITY_ID, UOW_ID, APPLICATION_HANDLE, DIRECT_IO, STMT_TEXT) ORDER BY DIRECT_IO DESC FETCH FIRST 10 ROWS ONLY); VALUES (1, CARDINALITY(ACT_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(ACT_ARRAY[I]),8,' ') || SPACE(2) || RPAD(VARCHAR(UOW_ARRAY[I]),6,' ') || SPACE(2)|| RPAD(VARCHAR(APP_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(IO_ARRAY[I]),14,' ') || SPACE(2)|| RPAD(STMT_ARRAY[I],33,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* ======================== */ /* part 2 - Overall summary */ /* ======================== */ SET LAST_IR = IR + 6; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(ACTIVITY_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(ACTIVITY_ID_ARRAY[I]),8,' ') || SPACE(2) || RPAD(VARCHAR(UOW_ID_ARRAY[I]),6,' ') || SPACE(2)|| RPAD(VARCHAR(APPLICATION_HANDLE_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(CPU_RANK_ARRAY[I]),9,' ') || SPACE(2)|| RPAD(VARCHAR(ROWS_RANK_ARRAY[I]),13,' ') || SPACE(2)|| RPAD(VARCHAR(IO_RANK_ARRAY[I]),22,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* =============================================== */ /* part 3 - Complete statement text for activities */ /* =============================================== */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(ACTIVITY_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO VALUES (VARCHAR(ACTIVITY_ID_ARRAY[I]) || '/' || VARCHAR(UOW_ID_ARRAY[I]) || '/' || VARCHAR(APPLICATION_HANDLE_ARRAY[I])) INTO ENTRY; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(ENTRY,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (1) INTO POS; WHILE (POS <= LENGTH(STMT_TEXT_ARRAY[I])) DO SET REPOUTPUT[IR] = SUBSTR(STMT_TEXT_ARRAY[I], POS, REP_WIDTH); VALUES (POS + REP_WIDTH, IR + 1) INTO POS, IR; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (IC - 3, I + 1) INTO IC, I; END WHILE; /* open cursor to return report as result set */ OPEN RES; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  DBSUMMARY ( IN TIMEINTERVAL INTEGER DEFAULT 10) SPECIFIC MONREPORT_DBSUMMARY LANGUAGE SQL DYNAMIC RESULT SETS 1 BEGIN DECLARE LOC VARCHAR(33); DECLARE REPOUTPUT, MSGCACHE, CR_MSGCACHE REPORT_TYPE; DECLARE DBNAME, TODAY VARCHAR(38); DECLARE I, L, IR, LAST_IR, IC, CR_IC, MSGCOUNT, MSGINDEX INTEGER; DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE CPU_PER_RQST, WAIT_TIME_PCT DOUBLE; DECLARE SC_SERVICE_CLASS_ID_ARRAY MONMETRICS_INT_TYPE; DECLARE WL_WORKLOAD_NAME_ARRAY MONMETRICS_CHAR128_TYPE; DECLARE PM_MEMBER_ARRAY MONMETRICS_SMALLINT_TYPE; DECLARE CN_APPLICATION_HANDLE_ARRAY, CN_TOTAL_APP_COMMITS_ARRAY, CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY, CN_TOTAL_RQST_TIME_ARRAY, CN_TOTAL_WAIT_TIME_ARRAY, CN_ROWS_READ_ARRAY, CN_ROWS_MODIFIED_ARRAY, CN_TOTAL_CPU_TIME_ARRAY, SC_TOTAL_APP_COMMITS_ARRAY, SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY, SC_TOTAL_RQST_TIME_ARRAY, SC_TOTAL_WAIT_TIME_ARRAY, SC_ROWS_READ_ARRAY, SC_ROWS_MODIFIED_ARRAY, SC_TOTAL_CPU_TIME_ARRAY, WL_TOTAL_APP_COMMITS_ARRAY, WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY, WL_TOTAL_RQST_TIME_ARRAY, WL_TOTAL_WAIT_TIME_ARRAY, WL_ROWS_READ_ARRAY, WL_ROWS_MODIFIED_ARRAY, WL_TOTAL_CPU_TIME_ARRAY, PM_RQSTS_COMPLETED_TOTAL_ARRAY, PM_TOTAL_RQST_TIME_ARRAY, PM_TOTAL_WAIT_TIME_ARRAY, PM_IO_WAIT_TIME_ARRAY, PM_TOTAL_CPU_TIME_ARRAY MONMETRICS_BIGINT_TYPE; DECLARE WLM_QUEUE_TIME_TOTAL, WLM_QUEUE_TIME_TOTAL2, AGENT_WAIT_TIME, AGENT_WAIT_TIME2, TCPIP_RECVS_TOTAL, TCPIP_RECVS_TOTAL2, TCPIP_SENDS_TOTAL, TCPIP_SENDS_TOTAL2, IPC_RECVS_TOTAL, IPC_RECVS_TOTAL2, IPC_SENDS_TOTAL, IPC_SENDS_TOTAL2, TCPIP_SEND_WAIT_TIME, TCPIP_SEND_WAIT_TIME2, TCPIP_RECV_WAIT_TIME, TCPIP_RECV_WAIT_TIME2, IPC_SEND_WAIT_TIME, IPC_SEND_WAIT_TIME2, IPC_RECV_WAIT_TIME, IPC_RECV_WAIT_TIME2, TCPIP_RECV_VOLUME, TCPIP_RECV_VOLUME2, IPC_RECV_VOLUME, IPC_RECV_VOLUME2, TCPIP_SEND_VOLUME, TCPIP_SEND_VOLUME2, IPC_SEND_VOLUME, IPC_SEND_VOLUME2, LOCK_ESCALS, LOCK_ESCALS2, LOCK_WAITS, LOCK_WAITS2, LOCK_TIMEOUTS, LOCK_TIMEOUTS2, DEADLOCKS, DEADLOCKS2, ACT_COMPLETED_TOTAL, ACT_COMPLETED_TOTAL2, ACT_ABORTED_TOTAL, ACT_ABORTED_TOTAL2, ACT_REJECTED_TOTAL, ACT_REJECTED_TOTAL2, APP_RQSTS_COMPLETED_TOTAL, APP_RQSTS_COMPLETED_TOTAL2, TOTAL_RQST_TIME, TOTAL_RQST_TIME2, TOTAL_CPU_TIME, TOTAL_CPU_TIME2, TOTAL_WAIT_TIME, TOTAL_WAIT_TIME2, TOTAL_ACT_TIME, TOTAL_ACT_TIME2, TOTAL_ACT_WAIT_TIME, TOTAL_ACT_WAIT_TIME2, ROWS_READ, ROWS_READ2, ROWS_RETURNED, ROWS_RETURNED2, ROWS_MODIFIED, ROWS_MODIFIED2, POOL_DATA_L_READS, POOL_DATA_L_READS2, POOL_INDEX_L_READS, POOL_INDEX_L_READS2, POOL_TEMP_DATA_L_READS, POOL_TEMP_DATA_L_READS2, POOL_TEMP_INDEX_L_READS, POOL_TEMP_INDEX_L_READS2, POOL_TEMP_XDA_L_READS, POOL_TEMP_XDA_L_READS2, POOL_XDA_L_READS, POOL_XDA_L_READS2, POOL_DATA_P_READS, POOL_DATA_P_READS2, POOL_INDEX_P_READS, POOL_INDEX_P_READS2, POOL_TEMP_DATA_P_READS, POOL_TEMP_DATA_P_READS2, POOL_TEMP_INDEX_P_READS, POOL_TEMP_INDEX_P_READS2, POOL_TEMP_XDA_P_READS, POOL_TEMP_XDA_P_READS2, POOL_XDA_P_READS, POOL_XDA_P_READS2, POOL_READ_TIME, POOL_READ_TIME2, POOL_WRITE_TIME, POOL_WRITE_TIME2, POOL_DATA_WRITES, POOL_DATA_WRITES2, POOL_INDEX_WRITES, POOL_INDEX_WRITES2, POOL_XDA_WRITES, POOL_XDA_WRITES2, DIRECT_READ_TIME, DIRECT_READ_TIME2, DIRECT_READS, DIRECT_READS2, DIRECT_READ_REQS, DIRECT_READ_REQS2, DIRECT_WRITE_TIME, DIRECT_WRITE_TIME2, DIRECT_WRITES, DIRECT_WRITES2, DIRECT_WRITE_REQS, DIRECT_WRITE_REQS2, LOG_DISK_WAIT_TIME, LOG_DISK_WAIT_TIME2, LOG_DISK_WAITS_TOTAL, LOG_DISK_WAITS_TOTAL2, NUM_LOG_BUFFER_FULL, NUM_LOG_BUFFER_FULL2, CLIENT_IDLE_WAIT_TIME, CLIENT_IDLE_WAIT_TIME2, LOCK_WAIT_TIME, LOCK_WAIT_TIME2, FCM_SEND_WAIT_TIME, FCM_SEND_WAIT_TIME2, TOTAL_SORTS, TOTAL_SORTS2, SORT_OVERFLOWS, SORT_OVERFLOWS2, POST_THRESHOLD_SORTS, POST_THRESHOLD_SORTS2, POST_SHRTHRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS2, FCM_SEND_VOLUME, FCM_SEND_VOLUME2, FCM_SENDS_TOTAL, FCM_SENDS_TOTAL2, FCM_RECV_VOLUME, FCM_RECV_VOLUME2, FCM_RECVS_TOTAL, FCM_RECVS_TOTAL2, WLM_QUEUE_ASSIGNMENTS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL2, FCM_RECV_WAIT_TIME, FCM_RECV_WAIT_TIME2, TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_PROC_TIME2, TOTAL_SECTION_SORT_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME2, TOTAL_COMPILE_PROC_TIME, TOTAL_COMPILE_PROC_TIME2, TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME2, TOTAL_COMMIT_PROC_TIME, TOTAL_COMMIT_PROC_TIME2, TOTAL_ROLLBACK_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME2, TOTAL_RUNSTATS_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME2, TOTAL_REORG_PROC_TIME, TOTAL_REORG_PROC_TIME2, TOTAL_LOAD_PROC_TIME, TOTAL_LOAD_PROC_TIME2, TOTAL_APP_COMMITS, TOTAL_APP_COMMITS2, TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_INVOCATIONS2, TOTAL_ROUTINE_TIME, TOTAL_ROUTINE_TIME2, TOTAL_COMPILATIONS, TOTAL_COMPILATIONS2, PKG_CACHE_INSERTS, PKG_CACHE_INSERTS2, PKG_CACHE_LOOKUPS, PKG_CACHE_LOOKUPS2, CAT_CACHE_INSERTS, CAT_CACHE_INSERTS2, CAT_CACHE_LOOKUPS, CAT_CACHE_LOOKUPS2, INT_COMMITS, INT_COMMITS2, TOTAL_APP_ROLLBACKS, TOTAL_APP_ROLLBACKS2, INT_ROLLBACKS, INT_ROLLBACKS2, TOTAL_RUNSTATS, TOTAL_RUNSTATS2, TOTAL_REORGS, TOTAL_REORGS2, TOTAL_LOADS, TOTAL_LOADS2 BIGINT; /* this cursor is used to return the report as a result set */ DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); /* check input argument */ IF (TIMEINTERVAL IS NULL) THEN SET TIMEINTERVAL = 10; ELSEIF ((TIMEINTERVAL < 0) OR (TIMEINTERVAL > 3600)) THEN CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'DBSUMMARY', 'TIMEINTERVAL' ); END IF; /* fetch and cache all localized text for building report output */ VALUES (12696, 49, 1, 1) INTO MSGINDEX, MSGCOUNT, IC, IR; CALL INITMSGCACHE(MSGCACHE,IC,MSGINDEX,MSGCOUNT,LOC); VALUES (12491, 171, 1) INTO MSGINDEX, MSGCOUNT, CR_IC; CALL INITMSGCACHE(CR_MSGCACHE,CR_IC,MSGINDEX,MSGCOUNT,LOC); /* IR is the index in the report output array */ /* IC is the index in the message cache array */ /* ==================================== */ /* collect metrics at start of interval */ /* ==================================== */ SELECT SUM(WLM_QUEUE_TIME_TOTAL) AS WLM_QUEUE_TIME_TOTAL, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(TCPIP_RECVS_TOTAL) AS TCPIP_RECVS_TOTAL, SUM(TCPIP_SENDS_TOTAL) AS TCPIP_SENDS_TOTAL, SUM(IPC_RECVS_TOTAL) AS IPC_RECVS_TOTAL, SUM(IPC_SENDS_TOTAL) AS IPC_SENDS_TOTAL, SUM(TCPIP_SEND_WAIT_TIME) AS TCPIP_SEND_WAIT_TIME, SUM(TCPIP_RECV_WAIT_TIME) AS TCPIP_RECV_WAIT_TIME, SUM(IPC_SEND_WAIT_TIME) AS IPC_SEND_WAIT_TIME, SUM(IPC_RECV_WAIT_TIME) AS IPC_RECV_WAIT_TIME, SUM(TCPIP_RECV_VOLUME) AS TCPIP_RECV_VOLUME, SUM(IPC_RECV_VOLUME) AS IPC_RECV_VOLUME, SUM(TCPIP_SEND_VOLUME) AS TCPIP_SEND_VOLUME, SUM(IPC_SEND_VOLUME) AS IPC_SEND_VOLUME, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_ABORTED_TOTAL) AS ACT_ABORTED_TOTAL, SUM(ACT_REJECTED_TOTAL) AS ACT_REJECTED_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(POOL_DATA_L_READS) AS POOL_DATA_L_READS, SUM(POOL_INDEX_L_READS) AS POOL_INDEX_L_READS, SUM(POOL_TEMP_DATA_L_READS) AS POOL_TEMP_DATA_L_READS, SUM(POOL_TEMP_INDEX_L_READS) AS POOL_TEMP_INDEX_L_READS, SUM(POOL_TEMP_XDA_L_READS) AS POOL_TEMP_XDA_L_READS, SUM(POOL_XDA_L_READS) AS POOL_XDA_L_READS, SUM(POOL_DATA_P_READS) AS POOL_DATA_P_READS, SUM(POOL_INDEX_P_READS) AS POOL_INDEX_P_READS, SUM(POOL_TEMP_DATA_P_READS) AS POOL_TEMP_DATA_P_READS, SUM(POOL_TEMP_INDEX_P_READS) AS POOL_TEMP_INDEX_P_READS, SUM(POOL_TEMP_XDA_P_READS) AS POOL_TEMP_XDA_P_READS, SUM(POOL_XDA_P_READS) AS POOL_XDA_P_READS, SUM(POOL_READ_TIME) AS POOL_READ_TIME, SUM(POOL_WRITE_TIME) AS POOL_WRITE_TIME, SUM(POOL_DATA_WRITES) AS POOL_DATA_WRITES, SUM(POOL_INDEX_WRITES) AS POOL_INDEX_WRITES, SUM(POOL_XDA_WRITES) AS POOL_XDA_WRITES, SUM(DIRECT_READ_TIME) AS DIRECT_READ_TIME, SUM(DIRECT_READS) AS DIRECT_READS, SUM(DIRECT_READ_REQS) AS DIRECT_READ_REQS, SUM(DIRECT_WRITE_TIME) AS DIRECT_WRITE_TIME, SUM(DIRECT_WRITES) AS DIRECT_WRITES, SUM(DIRECT_WRITE_REQS) AS DIRECT_WRITE_REQS, SUM(LOG_DISK_WAIT_TIME) AS LOG_DISK_WAIT_TIME, SUM(LOG_DISK_WAITS_TOTAL) AS LOG_DISK_WAITS_TOTAL, SUM(NUM_LOG_BUFFER_FULL) AS NUM_LOG_BUFFER_FULL, SUM(CLIENT_IDLE_WAIT_TIME) AS CLIENT_IDLE_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(FCM_SEND_WAIT_TIME) AS FCM_SEND_WAIT_TIME, SUM(TOTAL_SORTS) AS TOTAL_SORTS, SUM(SORT_OVERFLOWS) AS SORT_OVERFLOWS, SUM(POST_THRESHOLD_SORTS) AS POST_THRESHOLD_SORTS, SUM(POST_SHRTHRESHOLD_SORTS) AS POST_SHRTHRESHOLD_SORTS, SUM(FCM_SEND_VOLUME) AS FCM_SEND_VOLUME, SUM(FCM_SENDS_TOTAL) AS FCM_SENDS_TOTAL, SUM(FCM_RECV_VOLUME) AS FCM_RECV_VOLUME, SUM(FCM_RECVS_TOTAL) AS FCM_RECVS_TOTAL, SUM(WLM_QUEUE_ASSIGNMENTS_TOTAL) AS WLM_QUEUE_ASSIGNMENTS_TOTAL, SUM(FCM_RECV_WAIT_TIME) AS FCM_RECV_WAIT_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS TOTAL_SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS TOTAL_SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME) AS TOTAL_COMPILE_PROC_TIME, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS TOTAL_IMPLICIT_COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME) AS TOTAL_COMMIT_PROC_TIME, SUM(TOTAL_ROLLBACK_PROC_TIME) AS TOTAL_ROLLBACK_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME) AS TOTAL_RUNSTATS_PROC_TIME, SUM(TOTAL_REORG_PROC_TIME) AS TOTAL_REORG_PROC_TIME, SUM(TOTAL_LOAD_PROC_TIME) AS TOTAL_LOAD_PROC_TIME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_ROUTINE_INVOCATIONS) AS TOTAL_ROUTINE_INVOCATIONS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME, SUM(TOTAL_COMPILATIONS) AS TOTAL_COMPILATIONS, SUM(PKG_CACHE_INSERTS) AS PKG_CACHE_INSERTS, SUM(PKG_CACHE_LOOKUPS) AS PKG_CACHE_LOOKUPS, SUM(CAT_CACHE_INSERTS) AS CAT_CACHE_INSERTS, SUM(CAT_CACHE_LOOKUPS) AS CAT_CACHE_LOOKUPS, SUM(INT_COMMITS) AS INT_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(INT_ROLLBACKS) AS INT_ROLLBACKS, SUM(TOTAL_RUNSTATS) AS TOTAL_RUNSTATS, SUM(TOTAL_REORGS) AS TOTAL_REORGS, SUM(TOTAL_LOADS) AS TOTAL_LOADS INTO WLM_QUEUE_TIME_TOTAL, AGENT_WAIT_TIME, TCPIP_RECVS_TOTAL, TCPIP_SENDS_TOTAL, IPC_RECVS_TOTAL, IPC_SENDS_TOTAL, TCPIP_SEND_WAIT_TIME, TCPIP_RECV_WAIT_TIME, IPC_SEND_WAIT_TIME, IPC_RECV_WAIT_TIME, TCPIP_RECV_VOLUME, IPC_RECV_VOLUME, TCPIP_SEND_VOLUME, IPC_SEND_VOLUME, LOCK_ESCALS, LOCK_WAITS, LOCK_TIMEOUTS, DEADLOCKS, ACT_COMPLETED_TOTAL, ACT_ABORTED_TOTAL, ACT_REJECTED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_CPU_TIME, TOTAL_WAIT_TIME, TOTAL_ACT_TIME, TOTAL_ACT_WAIT_TIME, ROWS_READ, ROWS_RETURNED, ROWS_MODIFIED, POOL_DATA_L_READS, POOL_INDEX_L_READS, POOL_TEMP_DATA_L_READS, POOL_TEMP_INDEX_L_READS, POOL_TEMP_XDA_L_READS, POOL_XDA_L_READS, POOL_DATA_P_READS, POOL_INDEX_P_READS, POOL_TEMP_DATA_P_READS, POOL_TEMP_INDEX_P_READS, POOL_TEMP_XDA_P_READS, POOL_XDA_P_READS, POOL_READ_TIME, POOL_WRITE_TIME, POOL_DATA_WRITES, POOL_INDEX_WRITES, POOL_XDA_WRITES, DIRECT_READ_TIME, DIRECT_READS, DIRECT_READ_REQS, DIRECT_WRITE_TIME, DIRECT_WRITES, DIRECT_WRITE_REQS, LOG_DISK_WAIT_TIME, LOG_DISK_WAITS_TOTAL, NUM_LOG_BUFFER_FULL, CLIENT_IDLE_WAIT_TIME, LOCK_WAIT_TIME, FCM_SEND_WAIT_TIME, TOTAL_SORTS, SORT_OVERFLOWS, POST_THRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS, FCM_SEND_VOLUME, FCM_SENDS_TOTAL, FCM_RECV_VOLUME, FCM_RECVS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL, FCM_RECV_WAIT_TIME, TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME, TOTAL_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_COMMIT_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME, TOTAL_REORG_PROC_TIME, TOTAL_LOAD_PROC_TIME, TOTAL_APP_COMMITS, TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_TIME, TOTAL_COMPILATIONS, PKG_CACHE_INSERTS, PKG_CACHE_LOOKUPS, CAT_CACHE_INSERTS, CAT_CACHE_LOOKUPS, INT_COMMITS, TOTAL_APP_ROLLBACKS, INT_ROLLBACKS, TOTAL_RUNSTATS, TOTAL_REORGS, TOTAL_LOADS FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)); /* key metrics by service connection */ SELECT ARRAY_AGG(APPLICATION_HANDLE ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_READ ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_MODIFIED ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY APPLICATION_HANDLE) INTO CN_APPLICATION_HANDLE_ARRAY, CN_TOTAL_APP_COMMITS_ARRAY, CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY, CN_TOTAL_RQST_TIME_ARRAY, CN_TOTAL_WAIT_TIME_ARRAY, CN_ROWS_READ_ARRAY, CN_ROWS_MODIFIED_ARRAY, CN_TOTAL_CPU_TIME_ARRAY FROM (SELECT APPLICATION_HANDLE, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_CONNECTION(NULL, -2)) GROUP BY APPLICATION_HANDLE); /* key metrics by service class */ SELECT ARRAY_AGG(SERVICE_CLASS_ID ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(ROWS_READ ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(ROWS_MODIFIED ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY SERVICE_CLASS_ID) INTO SC_SERVICE_CLASS_ID_ARRAY, SC_TOTAL_APP_COMMITS_ARRAY, SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY, SC_TOTAL_RQST_TIME_ARRAY, SC_TOTAL_WAIT_TIME_ARRAY, SC_ROWS_READ_ARRAY, SC_ROWS_MODIFIED_ARRAY, SC_TOTAL_CPU_TIME_ARRAY FROM (SELECT SERVICE_CLASS_ID, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)) GROUP BY SERVICE_CLASS_ID); /* key metrics by workload */ SELECT ARRAY_AGG(WORKLOAD_NAME ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY WORKLOAD_NAME), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY WORKLOAD_NAME), ARRAY_AGG(ROWS_READ ORDER BY WORKLOAD_NAME), ARRAY_AGG(ROWS_MODIFIED ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY WORKLOAD_NAME) INTO WL_WORKLOAD_NAME_ARRAY, WL_TOTAL_APP_COMMITS_ARRAY, WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY, WL_TOTAL_RQST_TIME_ARRAY, WL_TOTAL_WAIT_TIME_ARRAY, WL_ROWS_READ_ARRAY, WL_ROWS_MODIFIED_ARRAY, WL_TOTAL_CPU_TIME_ARRAY FROM (SELECT WORKLOAD_NAME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_WORKLOAD(NULL, -2)) GROUP BY WORKLOAD_NAME); /* key metrics by member */ SELECT ARRAY_AGG(MEMBER ORDER BY MEMBER), ARRAY_AGG(RQSTS_COMPLETED_TOTAL ORDER BY MEMBER), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY MEMBER), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY MEMBER), ARRAY_AGG(IO_WAIT_TIME ORDER BY MEMBER), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY MEMBER) INTO PM_MEMBER_ARRAY, PM_RQSTS_COMPLETED_TOTAL_ARRAY, PM_TOTAL_RQST_TIME_ARRAY, PM_TOTAL_WAIT_TIME_ARRAY, PM_IO_WAIT_TIME_ARRAY, PM_TOTAL_CPU_TIME_ARRAY FROM (SELECT MEMBER, SUM(RQSTS_COMPLETED_TOTAL) AS RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)) GROUP BY MEMBER); /* ================================== */ /* collect metrics at end of interval */ /* ================================== */ IF (TIMEINTERVAL > 0) THEN CALL DBMS_ALERT.SLEEP(TIMEINTERVAL); SELECT SUM(WLM_QUEUE_TIME_TOTAL) AS WLM_QUEUE_TIME_TOTAL, SUM(AGENT_WAIT_TIME) AS AGENT_WAIT_TIME, SUM(TCPIP_RECVS_TOTAL) AS TCPIP_RECVS_TOTAL, SUM(TCPIP_SENDS_TOTAL) AS TCPIP_SENDS_TOTAL, SUM(IPC_RECVS_TOTAL) AS IPC_RECVS_TOTAL, SUM(IPC_SENDS_TOTAL) AS IPC_SENDS_TOTAL, SUM(TCPIP_SEND_WAIT_TIME) AS TCPIP_SEND_WAIT_TIME, SUM(TCPIP_RECV_WAIT_TIME) AS TCPIP_RECV_WAIT_TIME, SUM(IPC_SEND_WAIT_TIME) AS IPC_SEND_WAIT_TIME, SUM(IPC_RECV_WAIT_TIME) AS IPC_RECV_WAIT_TIME, SUM(TCPIP_RECV_VOLUME) AS TCPIP_RECV_VOLUME, SUM(IPC_RECV_VOLUME) AS IPC_RECV_VOLUME, SUM(TCPIP_SEND_VOLUME) AS TCPIP_SEND_VOLUME, SUM(IPC_SEND_VOLUME) AS IPC_SEND_VOLUME, SUM(LOCK_ESCALS) AS LOCK_ESCALS, SUM(LOCK_WAITS) AS LOCK_WAITS, SUM(LOCK_TIMEOUTS) AS LOCK_TIMEOUTS, SUM(DEADLOCKS) AS DEADLOCKS, SUM(ACT_COMPLETED_TOTAL) AS ACT_COMPLETED_TOTAL, SUM(ACT_ABORTED_TOTAL) AS ACT_ABORTED_TOTAL, SUM(ACT_REJECTED_TOTAL) AS ACT_REJECTED_TOTAL, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(TOTAL_ACT_TIME) AS TOTAL_ACT_TIME, SUM(TOTAL_ACT_WAIT_TIME) AS TOTAL_ACT_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_RETURNED) AS ROWS_RETURNED, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(POOL_DATA_L_READS) AS POOL_DATA_L_READS, SUM(POOL_INDEX_L_READS) AS POOL_INDEX_L_READS, SUM(POOL_TEMP_DATA_L_READS) AS POOL_TEMP_DATA_L_READS, SUM(POOL_TEMP_INDEX_L_READS) AS POOL_TEMP_INDEX_L_READS, SUM(POOL_TEMP_XDA_L_READS) AS POOL_TEMP_XDA_L_READS, SUM(POOL_XDA_L_READS) AS POOL_XDA_L_READS, SUM(POOL_DATA_P_READS) AS POOL_DATA_P_READS, SUM(POOL_INDEX_P_READS) AS POOL_INDEX_P_READS, SUM(POOL_TEMP_DATA_P_READS) AS POOL_TEMP_DATA_P_READS, SUM(POOL_TEMP_INDEX_P_READS) AS POOL_TEMP_INDEX_P_READS, SUM(POOL_TEMP_XDA_P_READS) AS POOL_TEMP_XDA_P_READS, SUM(POOL_XDA_P_READS) AS POOL_XDA_P_READS, SUM(POOL_READ_TIME) AS POOL_READ_TIME, SUM(POOL_WRITE_TIME) AS POOL_WRITE_TIME, SUM(POOL_DATA_WRITES) AS POOL_DATA_WRITES, SUM(POOL_INDEX_WRITES) AS POOL_INDEX_WRITES, SUM(POOL_XDA_WRITES) AS POOL_XDA_WRITES, SUM(DIRECT_READ_TIME) AS DIRECT_READ_TIME, SUM(DIRECT_READS) AS DIRECT_READS, SUM(DIRECT_READ_REQS) AS DIRECT_READ_REQS, SUM(DIRECT_WRITE_TIME) AS DIRECT_WRITE_TIME, SUM(DIRECT_WRITES) AS DIRECT_WRITES, SUM(DIRECT_WRITE_REQS) AS DIRECT_WRITE_REQS, SUM(LOG_DISK_WAIT_TIME) AS LOG_DISK_WAIT_TIME, SUM(LOG_DISK_WAITS_TOTAL) AS LOG_DISK_WAITS_TOTAL, SUM(NUM_LOG_BUFFER_FULL) AS NUM_LOG_BUFFER_FULL, SUM(CLIENT_IDLE_WAIT_TIME) AS CLIENT_IDLE_WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, SUM(FCM_SEND_WAIT_TIME) AS FCM_SEND_WAIT_TIME, SUM(TOTAL_SORTS) AS TOTAL_SORTS, SUM(SORT_OVERFLOWS) AS SORT_OVERFLOWS, SUM(POST_THRESHOLD_SORTS) AS POST_THRESHOLD_SORTS, SUM(POST_SHRTHRESHOLD_SORTS) AS POST_SHRTHRESHOLD_SORTS, SUM(FCM_SEND_VOLUME) AS FCM_SEND_VOLUME, SUM(FCM_SENDS_TOTAL) AS FCM_SENDS_TOTAL, SUM(FCM_RECV_VOLUME) AS FCM_RECV_VOLUME, SUM(FCM_RECVS_TOTAL) AS FCM_RECVS_TOTAL, SUM(WLM_QUEUE_ASSIGNMENTS_TOTAL) AS WLM_QUEUE_ASSIGNMENTS_TOTAL, SUM(FCM_RECV_WAIT_TIME) AS FCM_RECV_WAIT_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS TOTAL_SECTION_PROC_TIME, SUM(TOTAL_SECTION_SORT_PROC_TIME) AS TOTAL_SECTION_SORT_PROC_TIME, SUM(TOTAL_COMPILE_PROC_TIME) AS TOTAL_COMPILE_PROC_TIME, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS TOTAL_IMPLICIT_COMPILE_PROC_TIME, SUM(TOTAL_COMMIT_PROC_TIME) AS TOTAL_COMMIT_PROC_TIME, SUM(TOTAL_ROLLBACK_PROC_TIME) AS TOTAL_ROLLBACK_PROC_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME) AS TOTAL_RUNSTATS_PROC_TIME, SUM(TOTAL_REORG_PROC_TIME) AS TOTAL_REORG_PROC_TIME, SUM(TOTAL_LOAD_PROC_TIME) AS TOTAL_LOAD_PROC_TIME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(TOTAL_ROUTINE_INVOCATIONS) AS TOTAL_ROUTINE_INVOCATIONS, SUM(TOTAL_ROUTINE_TIME) AS TOTAL_ROUTINE_TIME, SUM(TOTAL_COMPILATIONS) AS TOTAL_COMPILATIONS, SUM(PKG_CACHE_INSERTS) AS PKG_CACHE_INSERTS, SUM(PKG_CACHE_LOOKUPS) AS PKG_CACHE_LOOKUPS, SUM(CAT_CACHE_INSERTS) AS CAT_CACHE_INSERTS, SUM(CAT_CACHE_LOOKUPS) AS CAT_CACHE_LOOKUPS, SUM(INT_COMMITS) AS INT_COMMITS, SUM(TOTAL_APP_ROLLBACKS) AS TOTAL_APP_ROLLBACKS, SUM(INT_ROLLBACKS) AS INT_ROLLBACKS, SUM(TOTAL_RUNSTATS) AS TOTAL_RUNSTATS, SUM(TOTAL_REORGS) AS TOTAL_REORGS, SUM(TOTAL_LOADS) AS TOTAL_LOADS INTO WLM_QUEUE_TIME_TOTAL2, AGENT_WAIT_TIME2, TCPIP_RECVS_TOTAL2, TCPIP_SENDS_TOTAL2, IPC_RECVS_TOTAL2, IPC_SENDS_TOTAL2, TCPIP_SEND_WAIT_TIME2, TCPIP_RECV_WAIT_TIME2, IPC_SEND_WAIT_TIME2, IPC_RECV_WAIT_TIME2, TCPIP_RECV_VOLUME2, IPC_RECV_VOLUME2, TCPIP_SEND_VOLUME2, IPC_SEND_VOLUME2, LOCK_ESCALS2, LOCK_WAITS2, LOCK_TIMEOUTS2, DEADLOCKS2, ACT_COMPLETED_TOTAL2, ACT_ABORTED_TOTAL2, ACT_REJECTED_TOTAL2, APP_RQSTS_COMPLETED_TOTAL2, TOTAL_RQST_TIME2, TOTAL_CPU_TIME2, TOTAL_WAIT_TIME2, TOTAL_ACT_TIME2, TOTAL_ACT_WAIT_TIME2, ROWS_READ2, ROWS_RETURNED2, ROWS_MODIFIED2, POOL_DATA_L_READS2, POOL_INDEX_L_READS2, POOL_TEMP_DATA_L_READS2, POOL_TEMP_INDEX_L_READS2, POOL_TEMP_XDA_L_READS2, POOL_XDA_L_READS2, POOL_DATA_P_READS2, POOL_INDEX_P_READS2, POOL_TEMP_DATA_P_READS2, POOL_TEMP_INDEX_P_READS2, POOL_TEMP_XDA_P_READS2, POOL_XDA_P_READS2, POOL_READ_TIME2, POOL_WRITE_TIME2, POOL_DATA_WRITES2, POOL_INDEX_WRITES2, POOL_XDA_WRITES2, DIRECT_READ_TIME2, DIRECT_READS2, DIRECT_READ_REQS2, DIRECT_WRITE_TIME2, DIRECT_WRITES2, DIRECT_WRITE_REQS2, LOG_DISK_WAIT_TIME2, LOG_DISK_WAITS_TOTAL2, NUM_LOG_BUFFER_FULL2, CLIENT_IDLE_WAIT_TIME2, LOCK_WAIT_TIME2, FCM_SEND_WAIT_TIME2, TOTAL_SORTS2, SORT_OVERFLOWS2, POST_THRESHOLD_SORTS2, POST_SHRTHRESHOLD_SORTS2, FCM_SEND_VOLUME2, FCM_SENDS_TOTAL2, FCM_RECV_VOLUME2, FCM_RECVS_TOTAL2, WLM_QUEUE_ASSIGNMENTS_TOTAL2, FCM_RECV_WAIT_TIME2, TOTAL_SECTION_PROC_TIME2, TOTAL_SECTION_SORT_PROC_TIME2, TOTAL_COMPILE_PROC_TIME2, TOTAL_IMPLICIT_COMPILE_PROC_TIME2, TOTAL_COMMIT_PROC_TIME2, TOTAL_ROLLBACK_PROC_TIME2, TOTAL_RUNSTATS_PROC_TIME2, TOTAL_REORG_PROC_TIME2, TOTAL_LOAD_PROC_TIME2, TOTAL_APP_COMMITS2, TOTAL_ROUTINE_INVOCATIONS2, TOTAL_ROUTINE_TIME2, TOTAL_COMPILATIONS2, PKG_CACHE_INSERTS2, PKG_CACHE_LOOKUPS2, CAT_CACHE_INSERTS2, CAT_CACHE_LOOKUPS2, INT_COMMITS2, TOTAL_APP_ROLLBACKS2, INT_ROLLBACKS2, TOTAL_RUNSTATS2, TOTAL_REORGS2, TOTAL_LOADS2 FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)); /* key metrics by connection */ SELECT ARRAY_AGG(APPLICATION_HANDLE ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY APPLICATION_HANDLE), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_READ ORDER BY APPLICATION_HANDLE), ARRAY_AGG(ROWS_MODIFIED ORDER BY APPLICATION_HANDLE), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY APPLICATION_HANDLE) INTO CN_APPLICATION_HANDLE_ARRAY, CN_TOTAL_APP_COMMITS_ARRAY, CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY, CN_TOTAL_RQST_TIME_ARRAY, CN_TOTAL_WAIT_TIME_ARRAY, CN_ROWS_READ_ARRAY, CN_ROWS_MODIFIED_ARRAY, CN_TOTAL_CPU_TIME_ARRAY FROM (SELECT A.APPLICATION_HANDLE, B.TOTAL_APP_COMMITS - A.TOTAL_APP_COMMITS AS TOTAL_APP_COMMITS, B.APP_RQSTS_COMPLETED_TOTAL - A.APP_RQSTS_COMPLETED_TOTAL AS APP_RQSTS_COMPLETED_TOTAL, B.TOTAL_RQST_TIME - A.TOTAL_RQST_TIME AS TOTAL_RQST_TIME, B.TOTAL_WAIT_TIME - A.TOTAL_WAIT_TIME AS TOTAL_WAIT_TIME, B.ROWS_READ - A.ROWS_READ AS ROWS_READ, B.ROWS_MODIFIED - A.ROWS_MODIFIED AS ROWS_MODIFIED, B.TOTAL_CPU_TIME - A.TOTAL_CPU_TIME AS TOTAL_CPU_TIME FROM (SELECT APPLICATION_HANDLE, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_CONNECTION(NULL, -2)) GROUP BY APPLICATION_HANDLE ) AS B, UNNEST (CN_APPLICATION_HANDLE_ARRAY, CN_TOTAL_APP_COMMITS_ARRAY, CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY, CN_TOTAL_RQST_TIME_ARRAY, CN_TOTAL_WAIT_TIME_ARRAY, CN_ROWS_READ_ARRAY, CN_ROWS_MODIFIED_ARRAY, CN_TOTAL_CPU_TIME_ARRAY ) AS A (APPLICATION_HANDLE, TOTAL_APP_COMMITS, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_WAIT_TIME, ROWS_READ, ROWS_MODIFIED, TOTAL_CPU_TIME ) WHERE A.APPLICATION_HANDLE = B.APPLICATION_HANDLE); /* key metrics by service class */ SELECT ARRAY_AGG(SERVICE_CLASS_ID ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(ROWS_READ ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(ROWS_MODIFIED ORDER BY SERVICE_CLASS_ID), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY SERVICE_CLASS_ID) INTO SC_SERVICE_CLASS_ID_ARRAY, SC_TOTAL_APP_COMMITS_ARRAY, SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY, SC_TOTAL_RQST_TIME_ARRAY, SC_TOTAL_WAIT_TIME_ARRAY, SC_ROWS_READ_ARRAY, SC_ROWS_MODIFIED_ARRAY, SC_TOTAL_CPU_TIME_ARRAY FROM (SELECT A.SERVICE_CLASS_ID, B.TOTAL_APP_COMMITS - A.TOTAL_APP_COMMITS AS TOTAL_APP_COMMITS, B.APP_RQSTS_COMPLETED_TOTAL - A.APP_RQSTS_COMPLETED_TOTAL AS APP_RQSTS_COMPLETED_TOTAL, B.TOTAL_RQST_TIME - A.TOTAL_RQST_TIME AS TOTAL_RQST_TIME, B.TOTAL_WAIT_TIME - A.TOTAL_WAIT_TIME AS TOTAL_WAIT_TIME, B.ROWS_READ - A.ROWS_READ AS ROWS_READ, B.ROWS_MODIFIED - A.ROWS_MODIFIED AS ROWS_MODIFIED, B.TOTAL_CPU_TIME - A.TOTAL_CPU_TIME AS TOTAL_CPU_TIME FROM (SELECT SERVICE_CLASS_ID, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)) GROUP BY SERVICE_CLASS_ID ) AS B, UNNEST (SC_SERVICE_CLASS_ID_ARRAY, SC_TOTAL_APP_COMMITS_ARRAY, SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY, SC_TOTAL_RQST_TIME_ARRAY, SC_TOTAL_WAIT_TIME_ARRAY, SC_ROWS_READ_ARRAY, SC_ROWS_MODIFIED_ARRAY, SC_TOTAL_CPU_TIME_ARRAY ) AS A (SERVICE_CLASS_ID, TOTAL_APP_COMMITS, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_WAIT_TIME, ROWS_READ, ROWS_MODIFIED, TOTAL_CPU_TIME ) WHERE A.SERVICE_CLASS_ID = B.SERVICE_CLASS_ID); /* key metrics by workload */ SELECT ARRAY_AGG(WORKLOAD_NAME ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_APP_COMMITS ORDER BY WORKLOAD_NAME), ARRAY_AGG(APP_RQSTS_COMPLETED_TOTAL ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY WORKLOAD_NAME), ARRAY_AGG(ROWS_READ ORDER BY WORKLOAD_NAME), ARRAY_AGG(ROWS_MODIFIED ORDER BY WORKLOAD_NAME), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY WORKLOAD_NAME) INTO WL_WORKLOAD_NAME_ARRAY, WL_TOTAL_APP_COMMITS_ARRAY, WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY, WL_TOTAL_RQST_TIME_ARRAY, WL_TOTAL_WAIT_TIME_ARRAY, WL_ROWS_READ_ARRAY, WL_ROWS_MODIFIED_ARRAY, WL_TOTAL_CPU_TIME_ARRAY FROM (SELECT A.WORKLOAD_NAME, B.TOTAL_APP_COMMITS - A.TOTAL_APP_COMMITS AS TOTAL_APP_COMMITS, B.APP_RQSTS_COMPLETED_TOTAL - A.APP_RQSTS_COMPLETED_TOTAL AS APP_RQSTS_COMPLETED_TOTAL, B.TOTAL_RQST_TIME - A.TOTAL_RQST_TIME AS TOTAL_RQST_TIME, B.TOTAL_WAIT_TIME - A.TOTAL_WAIT_TIME AS TOTAL_WAIT_TIME, B.ROWS_READ - A.ROWS_READ AS ROWS_READ, B.ROWS_MODIFIED - A.ROWS_MODIFIED AS ROWS_MODIFIED, B.TOTAL_CPU_TIME - A.TOTAL_CPU_TIME AS TOTAL_CPU_TIME FROM (SELECT WORKLOAD_NAME, SUM(TOTAL_APP_COMMITS) AS TOTAL_APP_COMMITS, SUM(APP_RQSTS_COMPLETED_TOTAL) AS APP_RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(ROWS_READ) AS ROWS_READ, SUM(ROWS_MODIFIED) AS ROWS_MODIFIED, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_WORKLOAD(NULL, -2)) GROUP BY WORKLOAD_NAME ) AS B, UNNEST (WL_WORKLOAD_NAME_ARRAY, WL_TOTAL_APP_COMMITS_ARRAY, WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY, WL_TOTAL_RQST_TIME_ARRAY, WL_TOTAL_WAIT_TIME_ARRAY, WL_ROWS_READ_ARRAY, WL_ROWS_MODIFIED_ARRAY, WL_TOTAL_CPU_TIME_ARRAY ) AS A (WORKLOAD_NAME, TOTAL_APP_COMMITS, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_WAIT_TIME, ROWS_READ, ROWS_MODIFIED, TOTAL_CPU_TIME ) WHERE A.WORKLOAD_NAME = B.WORKLOAD_NAME); /* key metrics by member */ SELECT ARRAY_AGG(MEMBER ORDER BY MEMBER), ARRAY_AGG(RQSTS_COMPLETED_TOTAL ORDER BY MEMBER), ARRAY_AGG(TOTAL_RQST_TIME ORDER BY MEMBER), ARRAY_AGG(TOTAL_WAIT_TIME ORDER BY MEMBER), ARRAY_AGG(IO_WAIT_TIME ORDER BY MEMBER), ARRAY_AGG(TOTAL_CPU_TIME ORDER BY MEMBER) INTO PM_MEMBER_ARRAY, PM_RQSTS_COMPLETED_TOTAL_ARRAY, PM_TOTAL_RQST_TIME_ARRAY, PM_TOTAL_WAIT_TIME_ARRAY, PM_IO_WAIT_TIME_ARRAY, PM_TOTAL_CPU_TIME_ARRAY FROM (SELECT A.MEMBER, B.RQSTS_COMPLETED_TOTAL - A.RQSTS_COMPLETED_TOTAL AS RQSTS_COMPLETED_TOTAL, B.TOTAL_RQST_TIME - A.TOTAL_RQST_TIME AS TOTAL_RQST_TIME, B.TOTAL_WAIT_TIME - A.TOTAL_WAIT_TIME AS TOTAL_WAIT_TIME, B.IO_WAIT_TIME - A.IO_WAIT_TIME AS IO_WAIT_TIME, B.TOTAL_CPU_TIME - A.TOTAL_CPU_TIME AS TOTAL_CPU_TIME FROM (SELECT MEMBER, SUM(RQSTS_COMPLETED_TOTAL) AS RQSTS_COMPLETED_TOTAL, SUM(TOTAL_RQST_TIME) AS TOTAL_RQST_TIME, SUM(TOTAL_WAIT_TIME) AS TOTAL_WAIT_TIME, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, SUM(TOTAL_CPU_TIME) AS TOTAL_CPU_TIME FROM TABLE(MON_GET_SERVICE_SUBCLASS(NULL, NULL, -2)) GROUP BY MEMBER ) AS B, UNNEST (PM_MEMBER_ARRAY, PM_RQSTS_COMPLETED_TOTAL_ARRAY, PM_TOTAL_RQST_TIME_ARRAY, PM_TOTAL_WAIT_TIME_ARRAY, PM_IO_WAIT_TIME_ARRAY, PM_TOTAL_CPU_TIME_ARRAY ) AS A (MEMBER, RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_WAIT_TIME, IO_WAIT_TIME, TOTAL_CPU_TIME ) WHERE A.MEMBER = B.MEMBER); /* compute difference for common request metrics */ VALUES (WLM_QUEUE_TIME_TOTAL2 - WLM_QUEUE_TIME_TOTAL, AGENT_WAIT_TIME2 - AGENT_WAIT_TIME, TCPIP_RECVS_TOTAL2 - TCPIP_RECVS_TOTAL, TCPIP_SENDS_TOTAL2 - TCPIP_SENDS_TOTAL, IPC_RECVS_TOTAL2 - IPC_RECVS_TOTAL, IPC_SENDS_TOTAL2 - IPC_SENDS_TOTAL, TCPIP_SEND_WAIT_TIME2 - TCPIP_SEND_WAIT_TIME, TCPIP_RECV_WAIT_TIME2 - TCPIP_RECV_WAIT_TIME, IPC_SEND_WAIT_TIME2 - IPC_SEND_WAIT_TIME, IPC_RECV_WAIT_TIME2 - IPC_RECV_WAIT_TIME, TCPIP_RECV_VOLUME2 - TCPIP_RECV_VOLUME, IPC_RECV_VOLUME2 - IPC_RECV_VOLUME, TCPIP_SEND_VOLUME2 - TCPIP_SEND_VOLUME, IPC_SEND_VOLUME2 - IPC_SEND_VOLUME, LOCK_ESCALS2 - LOCK_ESCALS, LOCK_WAITS2 - LOCK_WAITS, LOCK_TIMEOUTS2 - LOCK_TIMEOUTS, DEADLOCKS2 - DEADLOCKS, ACT_COMPLETED_TOTAL2 - ACT_COMPLETED_TOTAL, ACT_ABORTED_TOTAL2 - ACT_ABORTED_TOTAL, ACT_REJECTED_TOTAL2 - ACT_REJECTED_TOTAL, APP_RQSTS_COMPLETED_TOTAL2 - APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME2 - TOTAL_RQST_TIME, TOTAL_CPU_TIME2 - TOTAL_CPU_TIME, TOTAL_WAIT_TIME2 - TOTAL_WAIT_TIME, TOTAL_ACT_TIME2 - TOTAL_ACT_TIME, TOTAL_ACT_WAIT_TIME2 - TOTAL_ACT_WAIT_TIME, ROWS_READ2 - ROWS_READ, ROWS_RETURNED2 - ROWS_RETURNED, ROWS_MODIFIED2 - ROWS_MODIFIED, POOL_DATA_L_READS2 - POOL_DATA_L_READS, POOL_INDEX_L_READS2 - POOL_INDEX_L_READS, POOL_TEMP_DATA_L_READS2 - POOL_TEMP_DATA_L_READS, POOL_TEMP_INDEX_L_READS2 - POOL_TEMP_INDEX_L_READS, POOL_TEMP_XDA_L_READS2 - POOL_TEMP_XDA_L_READS, POOL_XDA_L_READS2 - POOL_XDA_L_READS, POOL_DATA_P_READS2 - POOL_DATA_P_READS, POOL_INDEX_P_READS2 - POOL_INDEX_P_READS, POOL_TEMP_DATA_P_READS2 - POOL_TEMP_DATA_P_READS, POOL_TEMP_INDEX_P_READS2 - POOL_TEMP_INDEX_P_READS, POOL_TEMP_XDA_P_READS2 - POOL_TEMP_XDA_P_READS, POOL_XDA_P_READS2 - POOL_XDA_P_READS, POOL_READ_TIME2 - POOL_READ_TIME, POOL_WRITE_TIME2 - POOL_WRITE_TIME, POOL_DATA_WRITES2 - POOL_DATA_WRITES, POOL_INDEX_WRITES2 - POOL_INDEX_WRITES, POOL_XDA_WRITES2 - POOL_XDA_WRITES, DIRECT_READ_TIME2 - DIRECT_READ_TIME, DIRECT_READS2 - DIRECT_READS, DIRECT_READ_REQS2 - DIRECT_READ_REQS, DIRECT_WRITE_TIME2 - DIRECT_WRITE_TIME, DIRECT_WRITES2 - DIRECT_WRITES, DIRECT_WRITE_REQS2 - DIRECT_WRITE_REQS, LOG_DISK_WAIT_TIME2 - LOG_DISK_WAIT_TIME, LOG_DISK_WAITS_TOTAL2 - LOG_DISK_WAITS_TOTAL, NUM_LOG_BUFFER_FULL2 - NUM_LOG_BUFFER_FULL, CLIENT_IDLE_WAIT_TIME2 - CLIENT_IDLE_WAIT_TIME, LOCK_WAIT_TIME2 - LOCK_WAIT_TIME, FCM_SEND_WAIT_TIME2 - FCM_SEND_WAIT_TIME, TOTAL_SORTS2 - TOTAL_SORTS, SORT_OVERFLOWS2 - SORT_OVERFLOWS, POST_THRESHOLD_SORTS2 - POST_THRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS2 - POST_SHRTHRESHOLD_SORTS, FCM_SEND_VOLUME2 - FCM_SEND_VOLUME, FCM_SENDS_TOTAL2 - FCM_SENDS_TOTAL, FCM_RECV_VOLUME2 - FCM_RECV_VOLUME, FCM_RECVS_TOTAL2 - FCM_RECVS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL2 - WLM_QUEUE_ASSIGNMENTS_TOTAL, FCM_RECV_WAIT_TIME2 - FCM_RECV_WAIT_TIME, TOTAL_SECTION_PROC_TIME2 - TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME2 - TOTAL_SECTION_SORT_PROC_TIME, TOTAL_COMPILE_PROC_TIME2 - TOTAL_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME2 - TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_COMMIT_PROC_TIME2 - TOTAL_COMMIT_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME2 - TOTAL_ROLLBACK_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME2 - TOTAL_RUNSTATS_PROC_TIME, TOTAL_REORG_PROC_TIME2 - TOTAL_REORG_PROC_TIME, TOTAL_LOAD_PROC_TIME2 - TOTAL_LOAD_PROC_TIME, TOTAL_APP_COMMITS2 - TOTAL_APP_COMMITS, TOTAL_ROUTINE_INVOCATIONS2 - TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_TIME2 - TOTAL_ROUTINE_TIME, TOTAL_COMPILATIONS2 - TOTAL_COMPILATIONS, PKG_CACHE_INSERTS2 - PKG_CACHE_INSERTS, PKG_CACHE_LOOKUPS2 - PKG_CACHE_LOOKUPS, CAT_CACHE_INSERTS2 - CAT_CACHE_INSERTS, CAT_CACHE_LOOKUPS2 - CAT_CACHE_LOOKUPS, INT_COMMITS2 - INT_COMMITS, TOTAL_APP_ROLLBACKS2 - TOTAL_APP_ROLLBACKS, INT_ROLLBACKS2 - INT_ROLLBACKS, TOTAL_RUNSTATS2 - TOTAL_RUNSTATS, TOTAL_REORGS2 - TOTAL_REORGS, TOTAL_LOADS2 - TOTAL_LOADS) INTO WLM_QUEUE_TIME_TOTAL, AGENT_WAIT_TIME, TCPIP_RECVS_TOTAL, TCPIP_SENDS_TOTAL, IPC_RECVS_TOTAL, IPC_SENDS_TOTAL, TCPIP_SEND_WAIT_TIME, TCPIP_RECV_WAIT_TIME, IPC_SEND_WAIT_TIME, IPC_RECV_WAIT_TIME, TCPIP_RECV_VOLUME, IPC_RECV_VOLUME, TCPIP_SEND_VOLUME, IPC_SEND_VOLUME, LOCK_ESCALS, LOCK_WAITS, LOCK_TIMEOUTS, DEADLOCKS, ACT_COMPLETED_TOTAL, ACT_ABORTED_TOTAL, ACT_REJECTED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_CPU_TIME, TOTAL_WAIT_TIME, TOTAL_ACT_TIME, TOTAL_ACT_WAIT_TIME, ROWS_READ, ROWS_RETURNED, ROWS_MODIFIED, POOL_DATA_L_READS, POOL_INDEX_L_READS, POOL_TEMP_DATA_L_READS, POOL_TEMP_INDEX_L_READS, POOL_TEMP_XDA_L_READS, POOL_XDA_L_READS, POOL_DATA_P_READS, POOL_INDEX_P_READS, POOL_TEMP_DATA_P_READS, POOL_TEMP_INDEX_P_READS, POOL_TEMP_XDA_P_READS, POOL_XDA_P_READS, POOL_READ_TIME, POOL_WRITE_TIME, POOL_DATA_WRITES, POOL_INDEX_WRITES, POOL_XDA_WRITES, DIRECT_READ_TIME, DIRECT_READS, DIRECT_READ_REQS, DIRECT_WRITE_TIME, DIRECT_WRITES, DIRECT_WRITE_REQS, LOG_DISK_WAIT_TIME, LOG_DISK_WAITS_TOTAL, NUM_LOG_BUFFER_FULL, CLIENT_IDLE_WAIT_TIME, LOCK_WAIT_TIME, FCM_SEND_WAIT_TIME, TOTAL_SORTS, SORT_OVERFLOWS, POST_THRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS, FCM_SEND_VOLUME, FCM_SENDS_TOTAL, FCM_RECV_VOLUME, FCM_RECVS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL, FCM_RECV_WAIT_TIME, TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME, TOTAL_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_COMMIT_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME, TOTAL_REORG_PROC_TIME, TOTAL_LOAD_PROC_TIME, TOTAL_APP_COMMITS, TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_TIME, TOTAL_COMPILATIONS, PKG_CACHE_INSERTS, PKG_CACHE_LOOKUPS, CAT_CACHE_INSERTS, CAT_CACHE_LOOKUPS, INT_COMMITS, TOTAL_APP_ROLLBACKS, INT_ROLLBACKS, TOTAL_RUNSTATS, TOTAL_REORGS, TOTAL_LOADS; END IF; /* =============================== */ /* start of report output - header */ /* =============================== */ VALUES (CURRENT SERVER) INTO DBNAME; SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(DBNAME,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(TODAY,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(TIMEINTERVAL),''); VALUES (IR+1, IC+1) INTO IR, IC; /* =========================== */ /* part 1 - System performance */ /* =========================== */ SET LAST_IR = IR + 3; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; CALL COMMONREQMETRICS (REPOUTPUT, IR, CR_MSGCACHE, TIMEINTERVAL, WLM_QUEUE_TIME_TOTAL, AGENT_WAIT_TIME, TCPIP_RECVS_TOTAL, TCPIP_SENDS_TOTAL, IPC_RECVS_TOTAL, IPC_SENDS_TOTAL, TCPIP_SEND_WAIT_TIME, TCPIP_RECV_WAIT_TIME, IPC_SEND_WAIT_TIME, IPC_RECV_WAIT_TIME, TCPIP_RECV_VOLUME, IPC_RECV_VOLUME, TCPIP_SEND_VOLUME, IPC_SEND_VOLUME, LOCK_ESCALS, LOCK_WAITS, LOCK_TIMEOUTS, DEADLOCKS, ACT_COMPLETED_TOTAL, ACT_ABORTED_TOTAL, ACT_REJECTED_TOTAL, APP_RQSTS_COMPLETED_TOTAL, TOTAL_RQST_TIME, TOTAL_CPU_TIME, TOTAL_WAIT_TIME, TOTAL_ACT_TIME, TOTAL_ACT_WAIT_TIME, ROWS_READ, ROWS_RETURNED, ROWS_MODIFIED, POOL_DATA_L_READS, POOL_INDEX_L_READS, POOL_TEMP_DATA_L_READS, POOL_TEMP_INDEX_L_READS, POOL_TEMP_XDA_L_READS, POOL_XDA_L_READS, POOL_DATA_P_READS, POOL_INDEX_P_READS, POOL_TEMP_DATA_P_READS, POOL_TEMP_INDEX_P_READS, POOL_TEMP_XDA_P_READS, POOL_XDA_P_READS, POOL_READ_TIME, POOL_WRITE_TIME, POOL_DATA_WRITES, POOL_INDEX_WRITES, POOL_XDA_WRITES, DIRECT_READ_TIME, DIRECT_READS, DIRECT_READ_REQS, DIRECT_WRITE_TIME, DIRECT_WRITES, DIRECT_WRITE_REQS, LOG_DISK_WAIT_TIME, LOG_DISK_WAITS_TOTAL, NUM_LOG_BUFFER_FULL, CLIENT_IDLE_WAIT_TIME, LOCK_WAIT_TIME, FCM_SEND_WAIT_TIME, TOTAL_SORTS, SORT_OVERFLOWS, POST_THRESHOLD_SORTS, POST_SHRTHRESHOLD_SORTS, FCM_SEND_VOLUME, FCM_SENDS_TOTAL, FCM_RECV_VOLUME, FCM_RECVS_TOTAL, WLM_QUEUE_ASSIGNMENTS_TOTAL, FCM_RECV_WAIT_TIME, TOTAL_SECTION_PROC_TIME, TOTAL_SECTION_SORT_PROC_TIME, TOTAL_COMPILE_PROC_TIME, TOTAL_IMPLICIT_COMPILE_PROC_TIME, TOTAL_COMMIT_PROC_TIME, TOTAL_ROLLBACK_PROC_TIME, TOTAL_RUNSTATS_PROC_TIME, TOTAL_REORG_PROC_TIME, TOTAL_LOAD_PROC_TIME, TOTAL_APP_COMMITS, TOTAL_ROUTINE_INVOCATIONS, TOTAL_ROUTINE_TIME, TOTAL_COMPILATIONS, PKG_CACHE_INSERTS, PKG_CACHE_LOOKUPS, CAT_CACHE_INSERTS, CAT_CACHE_LOOKUPS, INT_COMMITS, TOTAL_APP_ROLLBACKS, INT_ROLLBACKS, TOTAL_RUNSTATS, TOTAL_REORGS, TOTAL_LOADS); /* =========================================== */ /* part 2 - Application performance drill down */ /* =========================================== */ /* Application performance database-wide */ SET IC = IC - 1; SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (APP_RQSTS_COMPLETED_TOTAL > 0) THEN SET CPU_PER_RQST = DOUBLE(TOTAL_CPU_TIME) / DOUBLE(APP_RQSTS_COMPLETED_TOTAL); ELSE SET CPU_PER_RQST = 0; END IF; IF (TOTAL_RQST_TIME > 0) THEN SET WAIT_TIME_PCT = 100 * (DOUBLE(TOTAL_WAIT_TIME) / DOUBLE(TOTAL_RQST_TIME)); ELSE SET WAIT_TIME_PCT = 0; END IF; SET REPOUTPUT[IR] = RPAD(VARCHAR(DECIMAL(CPU_PER_RQST)),22,' ') || SPACE(2) || RPAD(VARCHAR(DECIMAL(WAIT_TIME_PCT)),11,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_APP_COMMITS),13,' ') || SPACE(2) || RPAD(VARCHAR(ROWS_READ + ROWS_MODIFIED),28,' '); SET IR = IR + 1; /* Application performance by connection */ SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; VALUES (1, CARDINALITY(CN_APPLICATION_HANDLE_ARRAY)) INTO I, L; WHILE (I <= L) DO IF (CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I] > 0) THEN SET CPU_PER_RQST = DOUBLE(CN_TOTAL_CPU_TIME_ARRAY[I]) / DOUBLE(CN_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I]); ELSE SET CPU_PER_RQST = 0; END IF; IF (CN_TOTAL_RQST_TIME_ARRAY[I] > 0) THEN SET WAIT_TIME_PCT = 100 * (DOUBLE(CN_TOTAL_WAIT_TIME_ARRAY[I]) / DOUBLE(CN_TOTAL_RQST_TIME_ARRAY[I])); ELSE SET WAIT_TIME_PCT = 0; END IF; SET REPOUTPUT[IR] = RPAD(VARCHAR(CN_APPLICATION_HANDLE_ARRAY[I]),8,' ') || SPACE(7) || RPAD(VARCHAR(DECIMAL(CPU_PER_RQST)),19,' ') || SPACE(3) || RPAD(VARCHAR(DECIMAL(WAIT_TIME_PCT)),11,' ') || SPACE(4) || RPAD(VARCHAR(CN_TOTAL_APP_COMMITS_ARRAY[I]),13,' ') || SPACE(2) || RPAD(VARCHAR(CN_ROWS_READ_ARRAY[I] + CN_ROWS_MODIFIED_ARRAY[I]),13,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* Application performance by service class */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(SC_SERVICE_CLASS_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO IF (SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I] > 0) THEN SET CPU_PER_RQST = DOUBLE(SC_TOTAL_CPU_TIME_ARRAY[I]) / DOUBLE(SC_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I]); ELSE SET CPU_PER_RQST = 0; END IF; IF (SC_TOTAL_RQST_TIME_ARRAY[I] > 0) THEN SET WAIT_TIME_PCT = 100 * (DOUBLE(SC_TOTAL_WAIT_TIME_ARRAY[I]) / DOUBLE(SC_TOTAL_RQST_TIME_ARRAY[I])); ELSE SET WAIT_TIME_PCT = 0; END IF; SET REPOUTPUT[IR] = RPAD(VARCHAR(SC_SERVICE_CLASS_ID_ARRAY[I]),8,' ') || SPACE(7) || RPAD(VARCHAR(DECIMAL(CPU_PER_RQST)),19,' ') || SPACE(3) || RPAD(VARCHAR(DECIMAL(WAIT_TIME_PCT)),11,' ') || SPACE(4) || RPAD(VARCHAR(SC_TOTAL_APP_COMMITS_ARRAY[I]),13,' ') || SPACE(2) || RPAD(VARCHAR(SC_ROWS_READ_ARRAY[I] + SC_ROWS_MODIFIED_ARRAY[I]),13,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* Application performance by workload */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(WL_WORKLOAD_NAME_ARRAY)) INTO I, L; WHILE (I <= L) DO IF (WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I] > 0) THEN SET CPU_PER_RQST = DOUBLE(WL_TOTAL_CPU_TIME_ARRAY[I]) / DOUBLE(WL_APP_RQSTS_COMPLETED_TOTAL_ARRAY[I]); ELSE SET CPU_PER_RQST = 0; END IF; IF (WL_TOTAL_RQST_TIME_ARRAY[I] > 0) THEN SET WAIT_TIME_PCT = 100 * (DOUBLE(WL_TOTAL_WAIT_TIME_ARRAY[I]) / DOUBLE(WL_TOTAL_RQST_TIME_ARRAY[I])); ELSE SET WAIT_TIME_PCT = 0; END IF; SET REPOUTPUT[IR] = RPAD(WL_WORKLOAD_NAME_ARRAY[I],13,' ') || SPACE(2) || RPAD(VARCHAR(DECIMAL(CPU_PER_RQST)),22,' ') || SPACE(2) || RPAD(VARCHAR(DECIMAL(WAIT_TIME_PCT)),11,' ') || SPACE(2) || RPAD(VARCHAR(WL_TOTAL_APP_COMMITS_ARRAY[I]),13,' ') || SPACE(2) || RPAD(VARCHAR(WL_ROWS_READ_ARRAY[I] + WL_ROWS_MODIFIED_ARRAY[I]),13,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; /* ================================= */ /* part 3 - Member level information */ /* ================================= */ SET LAST_IR = IR + 9; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1, CARDINALITY(PM_MEMBER_ARRAY)) INTO I, L; WHILE (I <= L) DO IF (PM_RQSTS_COMPLETED_TOTAL_ARRAY[I] > 0) THEN SET CPU_PER_RQST = DOUBLE(PM_TOTAL_CPU_TIME_ARRAY[I]) / DOUBLE(PM_RQSTS_COMPLETED_TOTAL_ARRAY[I]); ELSE SET CPU_PER_RQST = 0; END IF; IF (PM_TOTAL_RQST_TIME_ARRAY[I] > 0) THEN SET WAIT_TIME_PCT = 100 * (DOUBLE(PM_TOTAL_WAIT_TIME_ARRAY[I]) / DOUBLE(PM_TOTAL_RQST_TIME_ARRAY[I])); ELSE SET WAIT_TIME_PCT = 0; END IF; SET REPOUTPUT[IR] = RPAD(VARCHAR(PM_MEMBER_ARRAY[I]),6,' ') || SPACE(2) || RPAD(VARCHAR(DECIMAL(CPU_PER_RQST)),22,' ') || SPACE(2) || RPAD(VARCHAR(DECIMAL(WAIT_TIME_PCT)),11,' ') || SPACE(2) || RPAD(VARCHAR(PM_RQSTS_COMPLETED_TOTAL_ARRAY[I]),16,' ') || SPACE(2) || RPAD(VARCHAR(PM_IO_WAIT_TIME_ARRAY[I]),17,' '); VALUES (IR + 1, I + 1) INTO IR, I; END WHILE; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; /* open cursor to return report as result set */ OPEN RES; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  LOCKWAIT (  ) SPECIFIC MONREPORT_LOCKWAIT LANGUAGE SQL BEGIN DECLARE DBNAME VARCHAR(32); DECLARE TODAY VARCHAR(70); DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE LOCK_WAIT_START_TIME_ARRAY,REQ_LOCAL_START_TIME_ARRAY, HLD1_LOCAL_START_TIME_ARRAY, HLD_LOCAL_START_TIME_ARRAY                  MONMETRICS_TIMESTAMP_TYPE; DECLARE LOCK_NAME_ARRAY, LOCK_OBJECT_TYPE_ARRAY                          MONMETRICS_CHAR32_TYPE; DECLARE LOCK_MODE_ARRAY, LOCK_MODE_REQUESTED_ARRAY                       MONMETRICS_CHAR3_TYPE; DECLARE LOCK_STATUS_ARRAY, LOCK_ESCALATION_ARRAY                         MONMETRICS_CHAR_TYPE; DECLARE LOCK_ATTRIBUTES_ARRAY                                            MONMETRICS_CHAR16_TYPE; DECLARE REQ_APPLICATION_HANDLE_ARRAY,REQ_AGENT_ID_ARRAY, HLD_APPLICATION_HANDLE_ARRAY,HLD_AGENT_ID_ARRAY, HLD1_APPLICATION_HANDLE_ARRAY,HLD1_AGENT_ID_ARRAY, HLD2_APPLICATION_HANDLE_ARRAY                                            MONMETRICS_BIGINT_TYPE; DECLARE REQ_MEMBER_ARRAY,HLD_MEMBER_ARRAY,HLD1_MEMBER_ARRAY, HLD2_MEMBER_ARRAY                                                        MONMETRICS_SMALLINT_TYPE; DECLARE HLD_SESSION_AUTH_ID_ARRAY,REQ_SESSION_AUTH_ID_ARRAY              MONMETRICS_CHAR128_TYPE; DECLARE REQ_APPLICATION_NAME_ARRAY, HLD_APPLICATION_NAME_ARRAY           MONMETRICS_CHAR128_TYPE; DECLARE REQ_APPLICATION_ID_ARRAY, HLD_APPLICATION_ID_ARRAY               MONMETRICS_CHAR128_TYPE; DECLARE REQ_REQUEST_TYPE_ARRAY,REQ_ACTIVITY_TYPE_ARRAY, REQ_ACTIVITY_STATE_ARRAY, HLD_REQUEST_TYPE_ARRAY,HLD_ACTIVITY_TYPE_ARRAY, HLD_ACTIVITY_STATE_ARRAY, HLD_EVOBJECT_ARRAY,HLD_EVSTATE_ARRAY,HLD_EVTYPE_ARRAY, HLD1_REQUEST_TYPE_ARRAY,HLD1_ACTIVITY_TYPE_ARRAY, HLD1_ACTIVITY_STATE_ARRAY, HLD1_EVOBJECT_ARRAY,HLD1_EVSTATE_ARRAY,HLD1_EVTYPE_ARRAY                 MONMETRICS_CHAR32_TYPE; DECLARE REQ_ACTIVITY_ID_ARRAY, REQ_UOW_ID_ARRAY, HLD_ACTIVITY_ID_ARRAY, HLD_UOW_ID_ARRAY, HLD1_ACTIVITY_ID_ARRAY, HLD1_UOW_ID_ARRAY, HLD2_ACTIVITY_ID_ARRAY, HLD2_UOW_ID_ARRAY                                MONMETRICS_INT_TYPE; DECLARE REPOUTPUT,MSGCACHE,TABSCHEMA_ARRAY,TABNAME_ARRAY,ROWID_ARRAY             REPORT_TYPE; DECLARE REQ_PKG_CACHE_STMT_ARRAY, HLD_PKG_CACHE_STMT_ARRAY, HLD1_PKG_CACHE_STMT_ARRAY MONMETRICS_CLOB_TYPE; DECLARE I, L, POS, IR, msgindex, ind, reportid,ind2, hld_ind, hld_msgindex       integer default 1; DECLARE LOC VARCHAR(33); DECLARE REP_WIDTH INTEGER DEFAULT 80; DECLARE STMT CLOB(2M); DECLARE BLOCK CLOB(32672); DECLARE BLOCK_LEN INTEGER DEFAULT 32672; DECLARE STMT_LEN INTEGER; DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); SELECT ARRAY_AGG(A1.LOCK_WAIT_START_TIME), ARRAY_AGG(A1.LOCK_NAME), ARRAY_AGG(VARCHAR(A1.LOCK_OBJECT_TYPE)) , ARRAY_AGG(A1.LOCK_MODE), ARRAY_AGG(A1.LOCK_MODE_REQUESTED), ARRAY_AGG(VARCHAR(A1.LOCK_STATUS)), ARRAY_AGG(VARCHAR(A1.LOCK_ESCALATION)), ARRAY_AGG(VARCHAR(A1.LOCK_ATTRIBUTES)), ARRAY_AGG(VARCHAR(F1.VALUE,80)), ARRAY_AGG(VARCHAR(F2.VALUE,80)), ARRAY_AGG(VARCHAR(F3.VALUE,80)), ARRAY_AGG(A1.REQ_APPLICATION_HANDLE)  , ARRAY_AGG(A1.REQ_AGENT_TID)  , ARRAY_AGG(A1.REQ_MEMBER)   , ARRAY_AGG(A1.HLD_APPLICATION_HANDLE), ARRAY_AGG(A1.HLD_MEMBER), ARRAY_AGG(H.APPLICATION_NAME), ARRAY_AGG(H.APPLICATION_ID), ARRAY_AGG(H.SESSION_AUTH_ID), ARRAY_AGG(R.APPLICATION_NAME), ARRAY_AGG(R.APPLICATION_ID), ARRAY_AGG(R.SESSION_AUTH_ID), ARRAY_AGG(WA.REQUEST_TYPE), ARRAY_AGG(W.ACTIVITY_ID), ARRAY_AGG(W.UOW_ID), ARRAY_AGG(W.LOCAL_START_TIME), ARRAY_AGG(W.ACTIVITY_TYPE), ARRAY_AGG(W.ACTIVITY_STATE), ARRAY_AGG(P.STMT_TEXT) INTO LOCK_WAIT_START_TIME_ARRAY, LOCK_NAME_ARRAY, LOCK_OBJECT_TYPE_ARRAY , LOCK_MODE_ARRAY, LOCK_MODE_REQUESTED_ARRAY , LOCK_STATUS_ARRAY, LOCK_ESCALATION_ARRAY , LOCK_ATTRIBUTES_ARRAY, ROWID_ARRAY, TABSCHEMA_ARRAY, TABNAME_ARRAY , REQ_APPLICATION_HANDLE_ARRAY , REQ_AGENT_ID_ARRAY , REQ_MEMBER_ARRAY  , HLD_APPLICATION_HANDLE_ARRAY, HLD_MEMBER_ARRAY, HLD_APPLICATION_NAME_ARRAY, HLD_APPLICATION_ID_ARRAY, HLD_SESSION_AUTH_ID_ARRAY, REQ_APPLICATION_NAME_ARRAY, REQ_APPLICATION_ID_ARRAY, REQ_SESSION_AUTH_ID_ARRAY, REQ_REQUEST_TYPE_ARRAY, REQ_ACTIVITY_ID_ARRAY, REQ_UOW_ID_ARRAY, REQ_LOCAL_START_TIME_ARRAY, REQ_ACTIVITY_TYPE_ARRAY, REQ_ACTIVITY_STATE_ARRAY, REQ_PKG_CACHE_STMT_ARRAY FROM (SELECT LOCK_WAIT_START_TIME, LOCK_NAME, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_MODE_REQUESTED, LOCK_STATUS, LOCK_ESCALATION, LOCK_ATTRIBUTES, REQ_APPLICATION_HANDLE, REQ_AGENT_TID, REQ_MEMBER, REQ_EXECUTABLE_ID, HLD_APPLICATION_HANDLE, HLD_MEMBER  from TABLE( MON_GET_APPL_LOCKWAIT(null, -2)))  AS A1 LEFT OUTER JOIN TABLE(MON_FORMAT_LOCK_NAME(A1.LOCK_NAME)) AS F1 ON F1.NAME = 'ROWID' LEFT OUTER JOIN TABLE(MON_FORMAT_LOCK_NAME(A1.LOCK_NAME)) AS F2 ON F2.NAME = 'TABSCHEMA' LEFT OUTER JOIN TABLE(MON_FORMAT_LOCK_NAME(A1.LOCK_NAME)) AS F3 ON  F3.NAME = 'TABNAME' LEFT OUTER JOIN TABLE(MON_GET_CONNECTION(A1.HLD_APPLICATION_HANDLE,A1.HLD_MEMBER)) AS H ON (A1.HLD_APPLICATION_HANDLE = H.APPLICATION_HANDLE AND A1.HLD_MEMBER = H.MEMBER AND (A1.HLD_APPLICATION_HANDLE is NOT NULL)) LEFT OUTER JOIN TABLE(MON_GET_CONNECTION(A1.REQ_APPLICATION_HANDLE,A1.REQ_MEMBER)) AS R ON A1.REQ_APPLICATION_HANDLE = R.APPLICATION_HANDLE AND A1.REQ_MEMBER = R.MEMBER LEFT OUTER JOIN TABLE(WLM_GET_SERVICE_CLASS_AGENTS_V97(CAST(NULL AS VARCHAR(128)),CAST(NULL AS VARCHAR(128)),A1.REQ_APPLICATION_HANDLE,A1.REQ_MEMBER)) AS WA ON WA.AGENT_TID = A1.REQ_AGENT_TID AND WA.APPLICATION_HANDLE = A1.REQ_APPLICATION_HANDLE AND WA.DBPARTITIONNUM = A1.REQ_MEMBER LEFT OUTER JOIN TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(A1.REQ_APPLICATION_HANDLE,A1.REQ_MEMBER)) AS W ON WA.UOW_ID  = W.UOW_ID AND WA.ACTIVITY_ID = W.ACTIVITY_ID LEFT OUTER JOIN TABLE(MON_GET_PKG_CACHE_STMT (NULL, A1.REQ_EXECUTABLE_ID, NULL, A1.REQ_MEMBER )) AS P ON P.MEMBER = A1.REQ_MEMBER AND P.EXECUTABLE_ID = A1.REQ_EXECUTABLE_ID AND A1.REQ_EXECUTABLE_ID IS NOT NULL; /* Issue second query to aggregate agent data for the holding app */ SELECT ARRAY_AGG(A1.APPLICATION_HANDLE), ARRAY_AGG(A1.MEMBER), ARRAY_AGG(W.AGENT_TID), ARRAY_AGG(W.REQUEST_TYPE) , ARRAY_AGG(W.EVENT_STATE ), ARRAY_AGG(W.EVENT_OBJECT) , ARRAY_AGG(W.EVENT_TYPE), ARRAY_AGG(W.ACTIVITY_ID ), ARRAY_AGG(W.UOW_ID) INTO HLD1_APPLICATION_HANDLE_ARRAY, HLD1_MEMBER_ARRAY, HLD1_AGENT_ID_ARRAY, HLD1_REQUEST_TYPE_ARRAY,  HLD1_EVSTATE_ARRAY, HLD1_EVOBJECT_ARRAY, HLD1_EVTYPE_ARRAY, HLD1_ACTIVITY_ID_ARRAY, HLD1_UOW_ID_ARRAY FROM (SELECT DISTINCT H.APPLICATION_HANDLE , H.MEMBER FROM UNNEST(HLD_APPLICATION_HANDLE_ARRAY, HLD_MEMBER_ARRAY) AS H(APPLICATION_HANDLE, MEMBER )) AS A1 JOIN TABLE(WLM_GET_SERVICE_CLASS_AGENTS_V97(CAST(NULL AS VARCHAR(128)),CAST(NULL AS VARCHAR(128)), A1.APPLICATION_HANDLE,A1.MEMBER)) AS W ON (A1.APPLICATION_HANDLE = W.APPLICATION_HANDLE AND A1.MEMBER = W.DBPARTITIONNUM AND A1.APPLICATION_HANDLE IS NOT NULL); /* Issue third query to aggregate activity , stmt text data for the holding app */ SELECT ARRAY_AGG(A1.APPLICATION_HANDLE), ARRAY_AGG(A1.MEMBER), ARRAY_AGG(W.ACTIVITY_ID ), ARRAY_AGG(W.UOW_ID), ARRAY_AGG(W.LOCAL_START_TIME), ARRAY_AGG(W.ACTIVITY_TYPE) , ARRAY_AGG(W.ACTIVITY_STATE ), ARRAY_AGG(P.STMT_TEXT) INTO HLD2_APPLICATION_HANDLE_ARRAY, HLD2_MEMBER_ARRAY, HLD2_ACTIVITY_ID_ARRAY, HLD2_UOW_ID_ARRAY, HLD1_LOCAL_START_TIME_ARRAY, HLD1_ACTIVITY_TYPE_ARRAY,  HLD1_ACTIVITY_STATE_ARRAY, HLD1_PKG_CACHE_STMT_ARRAY FROM (SELECT DISTINCT H.APPLICATION_HANDLE , H.MEMBER FROM UNNEST(HLD_APPLICATION_HANDLE_ARRAY, HLD_MEMBER_ARRAY) AS H(APPLICATION_HANDLE, MEMBER )) AS A1 JOIN TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97(A1.APPLICATION_HANDLE,A1.MEMBER)) AS W ON ((A1.APPLICATION_HANDLE = W.APPLICATION_HANDLE) AND  (W.DBPARTITIONNUM = A1.MEMBER) AND (A1.APPLICATION_HANDLE IS NOT NULL)) LEFT OUTER JOIN TABLE(MON_GET_PKG_CACHE_STMT (NULL, W.EXECUTABLE_ID, NULL, A1.MEMBER )) AS P ON (P.MEMBER = A1.MEMBER AND P.EXECUTABLE_ID = W.EXECUTABLE_ID AND (W.EXECUTABLE_ID IS NOT NULL)); VALUES ((1),(1),(14000)) INTO IND, REPORTID, MSGINDEX; /* Format Data for the Report */ CALL INITMSGCACHE(MSGCACHE,IND,MSGINDEX,18,LOC); SET REPOUTPUT[IND] = MSGCACHE[IND]; SET REPOUTPUT[IND+1] = MSGCACHE[IND+1]; SET REPOUTPUT[IND+2] = MSGCACHE[IND+2]; VALUES CURRENT SERVER INTO DBNAME; SET REPOUTPUT[IND+3] = MSGCACHE[IND+3] || DBNAME; SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IND+4] = MSGCACHE[IND+4] || TODAY; SET REPOUTPUT[IND+5] = MSGCACHE[IND+5]; SET REPOUTPUT[IND+6] = MSGCACHE[IND+6]; SET REPOUTPUT[IND+7] = MSGCACHE[IND+7]; SET REPOUTPUT[IND+8] = MSGCACHE[IND+8]; SET REPOUTPUT[IND+9] = MSGCACHE[IND+13]; SET REPOUTPUT[IND+10] = MSGCACHE[IND+14]; SET REPOUTPUT[IND+11] = MSGCACHE[IND+15]; SET REPOUTPUT[IND+12] = MSGCACHE[IND+16]; SET REPOUTPUT[IND+13] = MSGCACHE[IND+17]; SET IND = IND + 14; SET MSGINDEX = MSGINDEX + 18; CALL INITMSGCACHE(MSGCACHE,IND2,MSGINDEX,52,LOC); /* remove new lines and tabs from REQ statement texts */ VALUES (1, CARDINALITY(REQ_PKG_CACHE_STMT_ARRAY)) INTO I, L; WHILE (I <= L) DO VALUES (1, REQ_PKG_CACHE_STMT_ARRAY[I]) INTO POS, STMT; VALUES CLOB(' ',0) INTO REQ_PKG_CACHE_STMT_ARRAY[I]; VALUES LENGTH(STMT) INTO STMT_LEN; WHILE (POS <= LENGTH(STMT)) DO VALUES SUBSTR(STMT, POS, MIN(BLOCK_LEN, STMT_LEN - POS + 1 )) INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0A', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0D', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'09', ' ') INTO BLOCK; VALUES (REQ_PKG_CACHE_STMT_ARRAY[I] || BLOCK) INTO REQ_PKG_CACHE_STMT_ARRAY[I]; VALUES (POS + BLOCK_LEN) INTO POS; END WHILE; VALUES (I + 1) INTO I; END WHILE; /* remove new lines and tabs from HLD1 statement texts */ VALUES (1, CARDINALITY(HLD1_PKG_CACHE_STMT_ARRAY)) INTO I, L; WHILE (I <= L) DO VALUES (1, HLD1_PKG_CACHE_STMT_ARRAY[I]) INTO POS, STMT; VALUES CLOB(' ',0) INTO HLD1_PKG_CACHE_STMT_ARRAY[I]; VALUES LENGTH(STMT) INTO STMT_LEN; WHILE (POS <= LENGTH(STMT)) DO VALUES SUBSTR(STMT, POS, MIN(BLOCK_LEN, STMT_LEN - POS + 1 )) INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0A', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'0D', ' ') INTO BLOCK; VALUES SYSIBM.REPLACE(BLOCK, X'09', ' ') INTO BLOCK; VALUES (HLD1_PKG_CACHE_STMT_ARRAY[I] || BLOCK) INTO HLD1_PKG_CACHE_STMT_ARRAY[I]; VALUES (POS + BLOCK_LEN) INTO POS; END WHILE; VALUES (I + 1) INTO I; END WHILE; /* Summary First */ SET IND2 = 1; WHILE (IND2 <= CARDINALITY(LOCK_NAME_ARRAY))DO SET REPOUTPUT[IND] = RPAD(CHAR(REPORTID),4) || SPACE(2) || RPAD(CHAR(REQ_APPLICATION_HANDLE_ARRAY[IND2]),15,' ') || SPACE(2) || RPAD(LOCK_MODE_REQUESTED_ARRAY[IND2],9,' ') || SPACE(2) || RPAD(coalesce(CHAR(HLD_APPLICATION_HANDLE_ARRAY[IND2]),' '),15,' ') || SPACE(2) || RPAD(LOCK_MODE_ARRAY[IND2],5,' ') || SPACE(2) || LOCK_OBJECT_TYPE_ARRAY[IND2]; VALUES ((IND2+1), (IND+1), (REPORTID+1)) INTO IND2, IND, REPORTID; END WHILE; /* Part 2 */ VALUES ((1), (1), (1)) INTO REPORTID, IND2, MSGINDEX; SET REPOUTPUT[IND]   = MSGCACHE[MSGINDEX]; SET REPOUTPUT[IND+1] = MSGCACHE[MSGINDEX+1]; SET REPOUTPUT[IND+2] = MSGCACHE[MSGINDEX+2]; SET REPOUTPUT[IND+3] = MSGCACHE[MSGINDEX+3]; VALUES ((IND+4), (MSGINDEX+4)) INTO IND, MSGINDEX; WHILE (IND2 <= CARDINALITY(LOCK_NAME_ARRAY)) DO SET REPOUTPUT[IND] = MSGCACHE[MSGINDEX] || CHAR(REPORTID) ; /* lock id */ SET REPOUTPUT[IND+1] = MSGCACHE[MSGINDEX+1] ; /* lock details */ SET REPOUTPUT[IND+2] = MSGCACHE[MSGINDEX+2]; SET REPOUTPUT[IND+3] = MSGCACHE[MSGINDEX+3]; SET REPOUTPUT[IND+4] = MSGCACHE[MSGINDEX+4]; SET REPOUTPUT[IND+5] = MSGCACHE[MSGINDEX+5]   || LOCK_NAME_ARRAY[IND2]; SET REPOUTPUT[IND+6] = MSGCACHE[MSGINDEX+6]   || LOCK_WAIT_START_TIME_ARRAY[IND2]; SET REPOUTPUT[IND+7] = MSGCACHE[MSGINDEX+7]   || LOCK_OBJECT_TYPE_ARRAY[IND2]; SET REPOUTPUT[IND+8] = MSGCACHE[MSGINDEX+8]   || coalesce(TABSCHEMA_ARRAY[IND2],' '); SET REPOUTPUT[IND+9] = MSGCACHE[MSGINDEX+9]   || coalesce(TABNAME_ARRAY[IND2],' '); SET REPOUTPUT[IND+10] = MSGCACHE[MSGINDEX+10] || coalesce(ROWID_ARRAY[IND2],' '); SET REPOUTPUT[IND+11] = MSGCACHE[MSGINDEX+11] || LOCK_STATUS_ARRAY[IND2]; SET REPOUTPUT[IND+12] = MSGCACHE[MSGINDEX+12] || LOCK_ATTRIBUTES_ARRAY[IND2]; SET REPOUTPUT[IND+13] = MSGCACHE[MSGINDEX+13] || LOCK_ESCALATION_ARRAY[IND2]; SET REPOUTPUT[IND+14] = MSGCACHE[MSGINDEX+14]; SET REPOUTPUT[IND+15] = MSGCACHE[MSGINDEX+15]; SET REPOUTPUT[IND+16] = MSGCACHE[MSGINDEX+16]; SET REPOUTPUT[IND+17] = MSGCACHE[MSGINDEX+17]; SET REPOUTPUT[IND+18] = MSGCACHE[MSGINDEX+18]; SET REPOUTPUT[IND+19] = MSGCACHE[MSGINDEX+19] || RPAD(CHAR(REQ_APPLICATION_HANDLE_ARRAY[IND2]),29,' ') || SPACE(2) || coalesce(CHAR(HLD_APPLICATION_HANDLE_ARRAY[IND2]),' '); SET REPOUTPUT[IND+20] = MSGCACHE[MSGINDEX+20] || RPAD(REQ_APPLICATION_ID_ARRAY[IND2],29,' ') || SPACE(2) || HLD_APPLICATION_ID_ARRAY[IND2]; SET REPOUTPUT[IND+21] = MSGCACHE[MSGINDEX+21] || RPAD(REQ_APPLICATION_NAME_ARRAY[IND2],29,' ') || SPACE(2) || HLD_APPLICATION_NAME_ARRAY[IND2]; SET REPOUTPUT[IND+22] = MSGCACHE[MSGINDEX+22] || RPAD(REQ_SESSION_AUTH_ID_ARRAY[IND2],29,' ') || SPACE(2) || HLD_SESSION_AUTH_ID_ARRAY[IND2]; SET REPOUTPUT[IND+23] = MSGCACHE[MSGINDEX+23] || RPAD(CHAR(REQ_MEMBER_ARRAY[IND2]),29,' ') || SPACE(2) || CHAR(HLD_MEMBER_ARRAY[IND2]); SET REPOUTPUT[IND+24] = MSGCACHE[MSGINDEX+24] || RPAD('-',29,' ') || SPACE(2) || LOCK_MODE_ARRAY[IND2]; SET REPOUTPUT[IND+25] = MSGCACHE[MSGINDEX+25] || RPAD(LOCK_MODE_REQUESTED_ARRAY[IND2],29,' ') || SPACE(2) || '-'; SET REPOUTPUT[IND+26] = MSGCACHE[MSGINDEX+26]; SET REPOUTPUT[IND+27] = MSGCACHE[MSGINDEX+27]; SET REPOUTPUT[IND+28] = MSGCACHE[MSGINDEX+28]; SELECT ARRAY_AGG(A1.AGENT_TID), ARRAY_AGG(A1.REQUEST_TYPE), ARRAY_AGG(A1.EVSTATE), ARRAY_AGG(A1.EVOBJECT),ARRAY_AGG(A1.EVTYPE), ARRAY_AGG(A1.ACTIVITY_ID), ARRAY_AGG(A1.UOW_ID) INTO   HLD_AGENT_ID_ARRAY,HLD_REQUEST_TYPE_ARRAY, HLD_EVSTATE_ARRAY, HLD_EVOBJECT_ARRAY, HLD_EVTYPE_ARRAY, HLD_ACTIVITY_ID_ARRAY, HLD_UOW_ID_ARRAY FROM   (SELECT W.AGENT_TID,W.REQUEST_TYPE,W.EVSTATE,W.EVOBJECT,W.EVTYPE,W.ACTIVITY_ID,W.UOW_ID FROM UNNEST(HLD1_APPLICATION_HANDLE_ARRAY, HLD1_MEMBER_ARRAY, HLD1_AGENT_ID_ARRAY, HLD1_REQUEST_TYPE_ARRAY, HLD1_EVSTATE_ARRAY,HLD1_EVOBJECT_ARRAY, HLD1_EVTYPE_ARRAY, HLD1_ACTIVITY_ID_ARRAY, HLD1_UOW_ID_ARRAY) AS W(APPLICATION_HANDLE, MEMBER, AGENT_TID, REQUEST_TYPE, EVSTATE, EVOBJECT, EVTYPE, ACTIVITY_ID, UOW_ID ) WHERE (HLD_APPLICATION_HANDLE_ARRAY[IND2] IS NOT NULL) AND W.APPLICATION_HANDLE = HLD_APPLICATION_HANDLE_ARRAY[IND2] AND W.MEMBER = HLD_MEMBER_ARRAY[IND2]) AS A1 ; VALUES ((1), (IND+29), (MSGINDEX+29)) INTO HLD_IND, IND, HLD_MSGINDEX; WHILE (HLD_IND <= CARDINALITY(HLD_AGENT_ID_ARRAY)) DO SET REPOUTPUT[IND]   =  MSGCACHE[HLD_MSGINDEX]     || COALESCE(CHAR(HLD_AGENT_ID_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+1] =  MSGCACHE[HLD_MSGINDEX+1]   || COALESCE(HLD_REQUEST_TYPE_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+2] =  MSGCACHE[HLD_MSGINDEX+2]   || COALESCE(HLD_EVSTATE_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+3] =  MSGCACHE[HLD_MSGINDEX+3]   || COALESCE(HLD_EVOBJECT_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+4] =  MSGCACHE[HLD_MSGINDEX+4]   || COALESCE(HLD_EVTYPE_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+5] =  MSGCACHE[HLD_MSGINDEX+5]   || COALESCE(CHAR(HLD_ACTIVITY_ID_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+6] =  MSGCACHE[HLD_MSGINDEX+6]   || COALESCE(CHAR(HLD_UOW_ID_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+7] =  MSGCACHE[HLD_MSGINDEX+7] ; VALUES ((IND+8), (HLD_IND+1)) INTO IND, HLD_IND; END WHILE; SELECT ARRAY_AGG(A1.ACTIVITY_ID), ARRAY_AGG(A1.UOW_ID), ARRAY_AGG(A1.LOCAL_START_TIME), ARRAY_AGG(A1.ACTIVITY_TYPE),ARRAY_AGG(A1.ACTIVITY_STATE), ARRAY_AGG(A1.PKG_CACHE_STMT) INTO   HLD_ACTIVITY_ID_ARRAY, HLD_UOW_ID_ARRAY, HLD_LOCAL_START_TIME_ARRAY, HLD_ACTIVITY_TYPE_ARRAY, HLD_ACTIVITY_STATE_ARRAY, HLD_PKG_CACHE_STMT_ARRAY FROM   (SELECT W.ACTIVITY_ID,W.UOW_ID,W.LOCAL_START_TIME,W.ACTIVITY_TYPE,W.ACTIVITY_STATE,W.PKG_CACHE_STMT FROM UNNEST(HLD2_APPLICATION_HANDLE_ARRAY, HLD2_MEMBER_ARRAY, HLD2_ACTIVITY_ID_ARRAY, HLD2_UOW_ID_ARRAY,HLD1_LOCAL_START_TIME_ARRAY, HLD1_ACTIVITY_TYPE_ARRAY, HLD1_ACTIVITY_STATE_ARRAY, HLD1_PKG_CACHE_STMT_ARRAY ) AS W(APPLICATION_HANDLE, MEMBER, ACTIVITY_ID, UOW_ID, LOCAL_START_TIME, ACTIVITY_TYPE,ACTIVITY_STATE,PKG_CACHE_STMT ) WHERE (HLD_APPLICATION_HANDLE_ARRAY[IND2] IS NOT NULL) AND W.APPLICATION_HANDLE = HLD_APPLICATION_HANDLE_ARRAY[IND2] AND W.MEMBER = HLD_MEMBER_ARRAY[IND2]) AS A1 ; SET REPOUTPUT[IND]   = MSGCACHE[HLD_MSGINDEX+8]; SET REPOUTPUT[IND+1] = MSGCACHE[HLD_MSGINDEX+9]; VALUES (IND + 2, (1), (HLD_MSGINDEX+10)) INTO IND, HLD_IND, HLD_MSGINDEX; /*-- Lock holder activities --  */ WHILE (HLD_IND <= CARDINALITY(HLD_ACTIVITY_ID_ARRAY)) DO SET REPOUTPUT[IND] =  MSGCACHE[HLD_MSGINDEX]     || COALESCE(CHAR(HLD_ACTIVITY_ID_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+1] =  MSGCACHE[HLD_MSGINDEX+1]   || COALESCE(CHAR(HLD_UOW_ID_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+2] =  MSGCACHE[HLD_MSGINDEX+2]   || COALESCE(CHAR(HLD_LOCAL_START_TIME_ARRAY[HLD_IND]),' '); SET REPOUTPUT[IND+3] =  MSGCACHE[HLD_MSGINDEX+3]   || COALESCE(HLD_ACTIVITY_TYPE_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+4] =  MSGCACHE[HLD_MSGINDEX+4]   || COALESCE(HLD_ACTIVITY_STATE_ARRAY[HLD_IND],' '); SET REPOUTPUT[IND+5] =  MSGCACHE[HLD_MSGINDEX+5] ; SET REPOUTPUT[IND+6] =  MSGCACHE[HLD_MSGINDEX+6] ; VALUES (1, IND+7) INTO POS, IR; WHILE (POS <= LENGTH(HLD_PKG_CACHE_STMT_ARRAY[HLD_IND])) DO SET REPOUTPUT[IR] = SUBSTR(HLD_PKG_CACHE_STMT_ARRAY[HLD_IND], POS, REP_WIDTH); VALUES (POS + REP_WIDTH, IR + 1) INTO POS, IR; END WHILE; SET REPOUTPUT[IR]=  MSGCACHE[HLD_MSGINDEX+7] ; VALUES ((IR+1), (HLD_IND+1)) INTO IND, HLD_IND; END WHILE; /*-- Lock requestor waiting agent --  */ SET REPOUTPUT[IND]     = MSGCACHE[HLD_MSGINDEX+8]; SET REPOUTPUT[IND+1]   = MSGCACHE[MSGINDEX+28]; SET REPOUTPUT[IND+2]  =  MSGCACHE[MSGINDEX+29]      || CHAR(REQ_AGENT_ID_ARRAY[IND2]); SET REPOUTPUT[IND+3]  =  MSGCACHE[MSGINDEX+30]      || REQ_REQUEST_TYPE_ARRAY[IND2]; SET REPOUTPUT[IND+4]  =  MSGCACHE[HLD_MSGINDEX]     || CHAR(REQ_ACTIVITY_ID_ARRAY[IND2]); SET REPOUTPUT[IND+5]  =  MSGCACHE[HLD_MSGINDEX+1]   || CHAR(REQ_UOW_ID_ARRAY[IND2]); SET REPOUTPUT[IND+6]  =  MSGCACHE[HLD_MSGINDEX+2]   || REQ_LOCAL_START_TIME_ARRAY[IND2]; SET REPOUTPUT[IND+7]  =  MSGCACHE[HLD_MSGINDEX+3]   || REQ_ACTIVITY_TYPE_ARRAY[IND2]; SET REPOUTPUT[IND+8]  =  MSGCACHE[HLD_MSGINDEX+4]   || REQ_ACTIVITY_STATE_ARRAY[IND2]; SET REPOUTPUT[IND+9]  =  MSGCACHE[HLD_MSGINDEX+5]   ; SET REPOUTPUT[IND+10] =  MSGCACHE[HLD_MSGINDEX+6]   ; VALUES (1, IND+11) INTO POS, IR; WHILE (POS <= LENGTH(REQ_PKG_CACHE_STMT_ARRAY[IND2])) DO SET REPOUTPUT[IR] = SUBSTR(REQ_PKG_CACHE_STMT_ARRAY[IND2], POS, REP_WIDTH); VALUES (POS + REP_WIDTH, IR + 1) INTO POS, IR; END WHILE; SET REPOUTPUT[IR] =  MSGCACHE[HLD_MSGINDEX+7]   ; VALUES ((IND2+1), (IR+1), (REPORTID+1)) INTO IND2, IND, REPORTID; END WHILE; OPEN res; END;

ALTER MODULE "SYSIBMADM"."MONREPORT" PUBLISH
	PROCEDURE  PKGCACHE (  IN CACHE_INTERVAL INTEGER DEFAULT NULL, IN SECTION_TYPE CHAR(1) DEFAULT NULL, IN MEMBER SMALLINT DEFAULT NULL) SPECIFIC MONREPORT_PKGCACHE LANGUAGE SQL DYNAMIC RESULT SETS 1 BEGIN DECLARE LOC VARCHAR(33); DECLARE REPOUTPUT, MSGCACHE REPORT_TYPE; DECLARE TODAY VARCHAR(70); DECLARE DBNAME VARCHAR(32); DECLARE I, L, IR, LAST_IR, IC, MSGCOUNT, MSGINDEX INTEGER; DECLARE DBMEMBER SMALLINT; DECLARE SEARCH_ARG CLOB; DECLARE DATE_COMPAT_ARRAY MONMETRICS_CHAR3_TYPE; DECLARE SAVED_EXEC_ID MONEXEC_TYPE; DECLARE SAVED_EXEC_STMT MONMETRICS_CHAR80_TYPE; DECLARE EXEC_NUM INTEGER DEFAULT 1; DECLARE LAST_EXEC_NUM INTEGER DEFAULT 0; DECLARE OUTPUT_WIDTH INTEGER DEFAULT 80; DECLARE POS, LEN INTEGER; DECLARE EXECUTABLE_ID_ARRAY MONMETRICS_CHAR32_TYPE; DECLARE TOTAL_CPU_TIME_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, ROWS_READ_MODIFIED_ARRAY, NUM_EXECUTIONS_ARRAY, IO_WAIT_TIME_ARRAY MONMETRICS_BIGINT_TYPE; DECLARE STMT_TEXT_ARRAY MONMETRICS_CHAR80_TYPE; /* this cursor is used to return the report as a result set */ DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT FROM UNNEST(REPOUTPUT) AS R(TEXT); SET LOC = SUBSTR(CURRENT LOCALE LC_MESSAGES,1,33); /* check input arguments */ IF (CACHE_INTERVAL IS NULL) THEN SET CACHE_INTERVAL = 0; ELSEIF ((CACHE_INTERVAL < 0) OR (CACHE_INTERVAL > 10080)) THEN CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'PKGCACHE', 'CACHE_INTERVAL' ); END IF; IF (CACHE_INTERVAL > 0) THEN SET SEARCH_ARG = '<modified_within>' || VARCHAR(CACHE_INTERVAL) || '</modified_within>'; ELSE SET SEARCH_ARG = NULL; END IF; IF (SECTION_TYPE IS NULL OR SECTION_TYPE = '') THEN SET SECTION_TYPE = NULL; ELSEIF (SECTION_TYPE = 'D' OR SECTION_TYPE = 'd') THEN SET SECTION_TYPE = 'D'; ELSEIF (SECTION_TYPE = 'S' OR SECTION_TYPE = 's') THEN SET SECTION_TYPE = 'S'; ELSE CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'PKGCACHE', 'SECTION_TYPE' ); END IF; IF (MEMBER IS NULL) THEN SET DBMEMBER = -2; ELSEIF (MEMBER >= 0) THEN SET DBMEMBER = MEMBER; ELSE CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'PKGCACHE', 'MEMBER' ); END IF; /* fetch and cache all localized text for building report output */ VALUES (12941, 76, 1, 1) INTO MSGINDEX, MSGCOUNT, IC, IR; /* IR is the index in the report output array */ /* IC is the index in the message cache array */ CALL INITMSGCACHE(MSGCACHE,IC,MSGINDEX,MSGCOUNT,LOC); /* =============================== */ /* start of report output - header */ /* =============================== */ VALUES (CURRENT SERVER) INTO DBNAME; SELECT ARRAY_AGG(VALUE) INTO DATE_COMPAT_ARRAY FROM SYSIBMADM.DBCFG WHERE NAME = 'date_compat'; IF (DATE_COMPAT_ARRAY[1] = 'ON') THEN VALUES (CURRENT DATE) INTO TODAY; ELSE VALUES (CURRENT DATE || SPACE(1) || CURRENT TIME) INTO TODAY; END IF; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(DBNAME,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(TODAY,''); VALUES (IR+1, IC+1) INTO IR, IC; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; IF (CACHE_INTERVAL = 0) THEN SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; ELSE SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(CACHE_INTERVAL),''); VALUES (IR+1, IC+1) INTO IR, IC; END IF; IF (SECTION_TYPE IS NULL) THEN SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 2; ELSEIF (SECTION_TYPE = 'D') THEN SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; ELSEIF (SECTION_TYPE = 'S') THEN SET IC = IC + 2; SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END IF; IF (DBMEMBER = -2) THEN SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; SET IC = IC + 1; ELSE SET IC = IC + 1; SET REPOUTPUT[IR] = MSGCACHE[IC] || COALESCE(VARCHAR(DBMEMBER),''); VALUES (IR+1, IC+1) INTO IR, IC; END IF; /* ================================= */ /* part 1 - Summaries by top metrics */ /* ================================= */ /* Top statements by TOTAL_CPU_TIME */ SET LAST_IR = IR + 8; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.CPU_TIME DESC), ARRAY_AGG(M.CPU_TIME ORDER BY M.CPU_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.CPU_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_CPU_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, SUM(TOTAL_CPU_TIME) AS CPU_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID ORDER BY CPU_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY CPU_TIME DESC), ARRAY_AGG(CPU_TIME ORDER BY CPU_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY CPU_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_CPU_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, TOTAL_CPU_TIME AS CPU_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL ORDER BY CPU_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_CPU_TIME_ARRAY[I]),11,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],63); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by TOTAL_CPU_TIME per exec */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.CPU_TIME DESC), ARRAY_AGG(M.CPU_TIME ORDER BY M.CPU_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.CPU_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_CPU_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(SUM(TOTAL_CPU_TIME) / SUM(NUM_COORD_EXEC_WITH_METRICS)) AS CPU_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID HAVING SUM(NUM_COORD_EXEC_WITH_METRICS) > 0 ORDER BY CPU_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY CPU_TIME DESC), ARRAY_AGG(CPU_TIME ORDER BY CPU_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY CPU_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_CPU_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(TOTAL_CPU_TIME / NUM_EXEC_WITH_METRICS) AS CPU_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL AND NUM_EXEC_WITH_METRICS > 0 ORDER BY CPU_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_CPU_TIME_ARRAY[I]),11,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],63); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by TOTAL_WAIT_TIME */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(M.WAIT_TIME ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(M.LOCK_WAIT_TIME ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, SUM(TOTAL_ACT_WAIT_TIME) AS WAIT_TIME, SUM(LOCK_WAIT_TIME) AS LOCK_WAIT_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID ORDER BY WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY WAIT_TIME DESC), ARRAY_AGG(WAIT_TIME ORDER BY WAIT_TIME DESC), ARRAY_AGG(LOCK_WAIT_TIME ORDER BY WAIT_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, TOTAL_ACT_WAIT_TIME AS WAIT_TIME, LOCK_WAIT_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL ORDER BY WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_ACT_WAIT_TIME_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(LOCK_WAIT_TIME_ARRAY[I]),11,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],50); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by TOTAL_WAIT_TIME per exec */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(M.WAIT_TIME ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(M.LOCK_WAIT_TIME ORDER BY M.WAIT_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(SUM(TOTAL_ACT_WAIT_TIME) / SUM(NUM_COORD_EXEC_WITH_METRICS)) AS WAIT_TIME, BIGINT(SUM(LOCK_WAIT_TIME) / SUM(NUM_COORD_EXEC_WITH_METRICS)) AS LOCK_WAIT_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID HAVING SUM(NUM_COORD_EXEC_WITH_METRICS) > 0 ORDER BY WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY WAIT_TIME DESC), ARRAY_AGG(WAIT_TIME ORDER BY WAIT_TIME DESC), ARRAY_AGG(LOCK_WAIT_TIME ORDER BY WAIT_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, TOTAL_ACT_WAIT_TIME_ARRAY, LOCK_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(TOTAL_ACT_WAIT_TIME / NUM_EXEC_WITH_METRICS) AS WAIT_TIME, BIGINT(LOCK_WAIT_TIME / NUM_EXEC_WITH_METRICS) AS LOCK_WAIT_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL AND NUM_EXEC_WITH_METRICS > 0 ORDER BY WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(TOTAL_ACT_WAIT_TIME_ARRAY[I]),11,' ') || SPACE(2)|| RPAD(VARCHAR(LOCK_WAIT_TIME_ARRAY[I]),11,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],50); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by ROWS_READ + ROWS_MODIFIED */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.ROWS_READ_MODIFIED DESC), ARRAY_AGG(M.ROWS_READ_MODIFIED ORDER BY M.ROWS_READ_MODIFIED DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.ROWS_READ_MODIFIED DESC) INTO EXECUTABLE_ID_ARRAY, ROWS_READ_MODIFIED_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, SUM(ROWS_READ + ROWS_MODIFIED) AS ROWS_READ_MODIFIED, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID ORDER BY ROWS_READ_MODIFIED DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY ROWS_READ_MODIFIED DESC), ARRAY_AGG(ROWS_READ_MODIFIED ORDER BY ROWS_READ_MODIFIED DESC), ARRAY_AGG(STMT_TEXT ORDER BY ROWS_READ_MODIFIED DESC) INTO EXECUTABLE_ID_ARRAY, ROWS_READ_MODIFIED_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, ROWS_READ + ROWS_MODIFIED AS ROWS_READ_MODIFIED, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL ORDER BY ROWS_READ_MODIFIED DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(ROWS_READ_MODIFIED_ARRAY[I]),13,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],61); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by ROWS_READ + ROWS_MODIFIED per exec */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.ROWS_READ_MODIFIED DESC), ARRAY_AGG(M.ROWS_READ_MODIFIED ORDER BY M.ROWS_READ_MODIFIED DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.ROWS_READ_MODIFIED DESC) INTO EXECUTABLE_ID_ARRAY, ROWS_READ_MODIFIED_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(SUM(ROWS_READ + ROWS_MODIFIED) / SUM(NUM_COORD_EXEC_WITH_METRICS)) AS ROWS_READ_MODIFIED, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID HAVING SUM(NUM_COORD_EXEC_WITH_METRICS) > 0 ORDER BY ROWS_READ_MODIFIED DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY ROWS_READ_MODIFIED DESC), ARRAY_AGG(ROWS_READ_MODIFIED ORDER BY ROWS_READ_MODIFIED DESC), ARRAY_AGG(STMT_TEXT ORDER BY ROWS_READ_MODIFIED DESC) INTO EXECUTABLE_ID_ARRAY, ROWS_READ_MODIFIED_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT((ROWS_READ + ROWS_MODIFIED) / NUM_EXEC_WITH_METRICS) AS ROWS_READ_MODIFIED, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL AND NUM_EXEC_WITH_METRICS > 0 ORDER BY ROWS_READ_MODIFIED DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(ROWS_READ_MODIFIED_ARRAY[I]),13,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],61); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by numer of executions */ SET LAST_IR = IR + 4; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.NUM_EXEC DESC), ARRAY_AGG(M.NUM_EXEC ORDER BY M.NUM_EXEC DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.NUM_EXEC DESC) INTO EXECUTABLE_ID_ARRAY, NUM_EXECUTIONS_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, SUM(NUM_COORD_EXEC) AS NUM_EXEC, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID ORDER BY NUM_EXEC DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY NUM_EXEC DESC), ARRAY_AGG(NUM_EXEC ORDER BY NUM_EXEC DESC), ARRAY_AGG(STMT_TEXT ORDER BY NUM_EXEC DESC) INTO EXECUTABLE_ID_ARRAY, NUM_EXECUTIONS_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, NUM_EXECUTIONS AS NUM_EXEC, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL ORDER BY NUM_EXEC DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(NUM_EXECUTIONS_ARRAY[I]),20,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],54); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by I/O wait time */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.IO_WAIT_TIME DESC), ARRAY_AGG(M.IO_WAIT_TIME ORDER BY M.IO_WAIT_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.IO_WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, IO_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID ORDER BY IO_WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY IO_WAIT_TIME DESC), ARRAY_AGG(IO_WAIT_TIME ORDER BY IO_WAIT_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY IO_WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, IO_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, (POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) AS IO_WAIT_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL ORDER BY IO_WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(IO_WAIT_TIME_ARRAY[I]),20,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],54); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* Top statements by I/O wait time per exec */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; IF (DBMEMBER = -2) THEN SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.IO_WAIT_TIME DESC), ARRAY_AGG(M.IO_WAIT_TIME ORDER BY M.IO_WAIT_TIME DESC), ARRAY_AGG(VARCHAR(P.STMT_TEXT,80) ORDER BY M.IO_WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, IO_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT(SUM(POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) / SUM(NUM_COORD_EXEC_WITH_METRICS)) AS IO_WAIT_TIME, MIN(MEMBER) AS MIN_MEMBER FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL GROUP BY EXECUTABLE_ID HAVING SUM(NUM_COORD_EXEC_WITH_METRICS) > 0 ORDER BY IO_WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ) AS M JOIN TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, NULL, DBMEMBER)) AS P ON P.EXECUTABLE_ID = M.EXECUTABLE_ID AND P.MEMBER = M.MIN_MEMBER; ELSE SELECT ARRAY_AGG(EXECUTABLE_ID ORDER BY IO_WAIT_TIME DESC), ARRAY_AGG(IO_WAIT_TIME ORDER BY IO_WAIT_TIME DESC), ARRAY_AGG(STMT_TEXT ORDER BY IO_WAIT_TIME DESC) INTO EXECUTABLE_ID_ARRAY, IO_WAIT_TIME_ARRAY, STMT_TEXT_ARRAY FROM (SELECT EXECUTABLE_ID, BIGINT((POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME) / NUM_EXEC_WITH_METRICS) AS IO_WAIT_TIME, VARCHAR(STMT_TEXT,80) AS STMT_TEXT FROM TABLE(MON_GET_PKG_CACHE_STMT(SECTION_TYPE, NULL, SEARCH_ARG, DBMEMBER)) WHERE EXECUTABLE_ID IS NOT NULL AND NUM_EXEC_WITH_METRICS > 0 ORDER BY IO_WAIT_TIME DESC FETCH FIRST 10 ROWS ONLY ); END IF; VALUES (1, CARDINALITY(EXECUTABLE_ID_ARRAY)) INTO I, L; WHILE (I <= L) DO CALL SAVE_EXEC_INFO (EXECUTABLE_ID_ARRAY[I], STMT_TEXT_ARRAY[I], SAVED_EXEC_ID, SAVED_EXEC_STMT, LAST_EXEC_NUM, EXEC_NUM); SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || RPAD(VARCHAR(IO_WAIT_TIME_ARRAY[I]),20,' ') || SPACE(2)|| CHAR(SAVED_EXEC_STMT[EXEC_NUM],54); VALUES (I + 1, IR + 1) INTO I, IR; END WHILE; /* ================================================ */ /* part 2 - EXECUTABLE_IDs for statements in part 1 */ /* ================================================ */ SET LAST_IR = IR + 5; WHILE (IR <= LAST_IR) DO SET REPOUTPUT[IR] = MSGCACHE[IC]; VALUES (IR+1, IC+1) INTO IR, IC; END WHILE; VALUES (1) INTO EXEC_NUM; WHILE (EXEC_NUM <= LAST_EXEC_NUM) DO SET REPOUTPUT[IR] = RPAD(VARCHAR(EXEC_NUM),2,' ') || SPACE(2) || 'x''' || HEX(SAVED_EXEC_ID[EXEC_NUM]) || ''''; VALUES (EXEC_NUM + 1, IR + 1) INTO EXEC_NUM, IR; END WHILE; /* open cursor to return report as result set */ OPEN RES; END /* of procedure */;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  CREATE_DIRECTORY_INTERNAL        (          alias VARCHAR(128),          path VARCHAR(1024)        )        SPECIFIC UTL_DIR_CREATE_DIRECTORY_INTERNAL        BEGIN         DECLARE stmt VARCHAR(200);          DECLARE EXIT HANDLER FOR SQLSTATE '23505'          BEGIN            /* SIGNAL SQLSTATE '23505' SET MESSAGE_TEXT = 'directory alias already defined'; */            CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -601, alias, 'UTL_DIR', NULL );          END;                   IF alias is NULL OR TRIM(alias) is NULL OR LENGTH(TRIM(alias)) = 0 THEN            CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_DIR.CREATE_DIRECTORY', 'ALIAS' );          END IF;                  SET stmt = 'INSERT INTO SYSTOOLS.DIRECTORIES VALUES (:alias, :path, CURRENT USER)';         PREPARE S1 FROM stmt;         EXECUTE S1 USING alias, path;        END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  CREATE_OR_REPLACE_DIRECTORY_INTERNAL       (         alias VARCHAR(128),         path VARCHAR(1024)       )       SPECIFIC UTL_DIR_CREATE_OR_REPLACE_DIRECTORY_INTERNAL       BEGIN        DECLARE stmt VARCHAR(200);        DECLARE stmt2 VARCHAR(200);        DECLARE EXIT HANDLER FOR SQLSTATE '23505'        BEGIN          SET stmt2 = 'DELETE FROM SYSTOOLS.DIRECTORIES WHERE DIRALIAS = :alias';          PREPARE S2 FROM stmt2;          EXECUTE S2 USING alias;                   SET stmt2 = 'INSERT INTO SYSTOOLS.DIRECTORIES VALUES (:alias, :path, CURRENT USER)';          PREPARE S2 FROM stmt2;          EXECUTE S2 USING alias, path;        END;               IF alias is NULL OR TRIM(alias) is NULL OR LENGTH(TRIM(alias)) = 0 THEN          CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_DIR.CREATE_OR_REPLACE_DIRECTORY', 'ALIAS' );        END IF;               SET stmt = 'INSERT INTO SYSTOOLS.DIRECTORIES VALUES (:alias, :path, CURRENT USER)';        PREPARE S1 FROM stmt;        EXECUTE S1 USING alias, path;      END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  DROP_DIRECTORY_INTERNAL       (         alias VARCHAR(128)       )       SPECIFIC UTL_DIR_DROP_DIRECTORY_INTERNAL       BEGIN        DECLARE stmt VARCHAR(200);         DECLARE EXIT HANDLER FOR SQLSTATE '02000'         BEGIN           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -204, alias );         END;                SET stmt = 'DELETE FROM SYSTOOLS.DIRECTORIES WHERE DIRALIAS = :alias';        PREPARE S1 FROM stmt;        EXECUTE S1 USING alias;       END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  GET_DIRECTORY_PATH_INTERNAL       (         alias VARCHAR(128),         OUT path VARCHAR(1024)       )       SPECIFIC UTL_DIR_GET_DIRECTORY_PATH_INTERNAL       READS SQL DATA       BEGIN         DECLARE stmt VARCHAR(200);         DECLARE C1 CURSOR FOR S1;         /* If SYSTOOLS.DIRECTORIES does not exist, no directory alias exists */         DECLARE EXIT HANDLER FOR SQLSTATE '42704'         BEGIN         END;                SET stmt = 'SELECT DIRPATH FROM SYSTOOLS.DIRECTORIES WHERE DIRALIAS = :alias FOR READ ONLY';         PREPARE S1 FROM stmt;                 OPEN C1 USING alias;         FETCH C1 INTO path;         CLOSE C1;               END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  INIT()       SPECIFIC UTL_DIR_INIT       AUTONOMOUS        BEGIN          /* Creates the SYSTOOLS.DBMS_ALERT_INFO table in SYSTOOLSPACE */          CALL SYSINSTALLOBJECTS( 'UTL_DIR', 'C', NULL, NULL );        END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" ADD
	PROCEDURE  MY_SYS_INIT()       SPECIFIC UTL_DIR_MY_SYS_INIT        BEGIN          DECLARE found INTEGER;          DECLARE SQLCODE1 INTEGER;          DECLARE SQLCODE  INTEGER;                   /* Ignore error related to object that already exists */          DECLARE CONTINUE HANDLER FOR SQLSTATE '42710'            SET SQLCODE1 = SQLCODE;                   SELECT COUNT(*) INTO found FROM SYSCAT.TABLES            WHERE TABSCHEMA = 'SYSTOOLS' AND TABNAME = 'DIRECTORIES';                   IF found = 0 THEN            CALL UTL_DIR.INIT();          END IF;        END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" PUBLISH
	PROCEDURE  CREATE_DIRECTORY       (         alias VARCHAR(128),         path VARCHAR(1024)       )       SPECIFIC UTL_DIR_CREATE_DIRECTORY       BEGIN        CALL UTL_DIR.MY_SYS_INIT();                 CALL UTL_DIR.CREATE_DIRECTORY_INTERNAL( alias, path );       END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" PUBLISH
	PROCEDURE  CREATE_OR_REPLACE_DIRECTORY       (         alias VARCHAR(128),         path VARCHAR(1024)       )       SPECIFIC UTL_DIR_CREATE_OR_REPLACE_DIRECTORY       BEGIN        CALL UTL_DIR.MY_SYS_INIT();                 CALL UTL_DIR.CREATE_OR_REPLACE_DIRECTORY_INTERNAL( alias, path );       END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" PUBLISH
	PROCEDURE  DROP_DIRECTORY       (         alias VARCHAR(128)       )       SPECIFIC UTL_DIR_DROP_DIRECTORY       BEGIN        CALL UTL_DIR.MY_SYS_INIT();                 CALL UTL_DIR.DROP_DIRECTORY_INTERNAL( alias );       END;

ALTER MODULE "SYSIBMADM"."UTL_DIR" PUBLISH
	PROCEDURE  GET_DIRECTORY_PATH       (         alias VARCHAR(128),         OUT path VARCHAR(1024)       )       SPECIFIC UTL_DIR_GET_DIRECTORY_PATH       READS SQL DATA       BEGIN         CALL UTL_DIR.GET_DIRECTORY_PATH_INTERNAL( alias, path );       END;

ALTER MODULE "SYSIBMADM"."UTL_ENCODE" ADD
	PROCEDURE  "IMP_BASE64_ENCODE"(SOURCEDATA BLOB(10485760),
		OUT DESTDDATA BLOB(15728640),
		OUT RETURNVALUE INTEGER)
	SPECIFIC UTL_ENCODE_IMP_BASE64_ENCODE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_encode_base64_encode';

ALTER MODULE "SYSIBMADM"."UTL_ENCODE" PUBLISH
	PROCEDURE  BASE64_ENCODE(r BLOB(10M), OUT encodedData BLOB(15M))       SPECIFIC UTL_ENCODE_BASE64_ENCODE       LANGUAGE SQL     BEGIN       DECLARE retVal INTEGER;             CALL UTL_ENCODE.imp_BASE64_ENCODE(r, encodedData, retVal);     END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	FUNCTION  "IMP_FOPEN"(LOCATION VARCHAR(1024),
		FILENAME VARCHAR(255),
		OPEN_MODE VARCHAR(10),
		MAX_LINESIZE INTEGER)
	RETURNS "SYSIBMADM"."UTL_FILE"."FILE_TYPE"
	LANGUAGE C
	SPECIFIC UTL_FILE_IMP_FOPEN
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_FCOPY"(DIRNAME VARCHAR(1024),
		FILENAME VARCHAR(255),
		DESTDIR VARCHAR(1024),
		DESTFILE VARCHAR(255),
		BEGIN INTEGER,
		END INTEGER)
	SPECIFIC UTL_FILE_IMP_FCOPY
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_fcopy';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_FREMOVE"(DIRNAME VARCHAR(1024),
		FILENAME VARCHAR(255))
	SPECIFIC UTL_FILE_IMP_FREMOVE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_fremove';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_FRENAME"(DIRNAME VARCHAR(1024),
		FILENAME VARCHAR(255),
		DESTDIR VARCHAR(1024),
		DESTFILE VARCHAR(255),
		REPLACE INTEGER)
	SPECIFIC UTL_FILE_IMP_FRENAME
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_frename';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_IS_OPEN"(FILE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		OUT IS_OPEN INTEGER)
	SPECIFIC UTL_FILE_IMP_IS_OPEN
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_is_open';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_NEW_LINE"(FILETYPE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		NUMEOL BIGINT)
	SPECIFIC UTL_FILE_IMP_NEW_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_new_line';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_PUTF"(FILETYPE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		FORMAT VARCHAR(32672),
		ARGC SMALLINT,
		ARG1 VARCHAR(1024),
		ARG2 VARCHAR(1024),
		ARG3 VARCHAR(1024),
		ARG4 VARCHAR(1024),
		ARG5 VARCHAR(1024))
	SPECIFIC UTL_FILE_IMP_PUTF
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_putf';

ALTER MODULE "SYSIBMADM"."UTL_FILE" ADD
	PROCEDURE  "IMP_PUT_LINE"(FILETYPE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		LINE VARCHAR(32672))
	SPECIFIC UTL_FILE_IMP_PUT_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_put_line';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	FUNCTION  FOPEN(location VARCHAR(128), filename VARCHAR(255), open_mode VARCHAR(10))       SPECIFIC UTL_FILE_FOPEN_2       RETURNS UTL_FILE.FILE_TYPE       LANGUAGE SQL       BEGIN         DECLARE dirPath VARCHAR(1024) DEFAULT NULL;                 CALL UTL_DIR.GET_DIRECTORY_PATH(location, dirPath);        RETURN UTL_FILE.imp_FOPEN(dirPath, filename, open_mode, 1024);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	FUNCTION  FOPEN(location VARCHAR(128), filename VARCHAR(255), open_mode VARCHAR(10), max_linesize INTEGER)       SPECIFIC UTL_FILE_FOPEN       RETURNS UTL_FILE.FILE_TYPE       READS SQL DATA       LANGUAGE SQL       BEGIN         DECLARE dirPath VARCHAR(1024) DEFAULT NULL;                 CALL UTL_DIR.GET_DIRECTORY_PATH(location, dirPath);        RETURN UTL_FILE.imp_FOPEN(dirPath, filename, open_mode, max_linesize);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	FUNCTION  IS_OPEN(file UTL_FILE.FILE_TYPE)       SPECIFIC UTL_FILE_IS_OPEN       RETURNS BOOLEAN       READS SQL DATA       LANGUAGE SQL       BEGIN         DECLARE flag INTEGER;                 CALL UTL_FILE.imp_IS_OPEN(file, flag);        RETURN( CASE flag WHEN 0 THEN false ELSE true END );       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  "FCLOSE"(FILE "SYSIBMADM"."UTL_FILE"."FILE_TYPE")
	SPECIFIC UTL_FILE_FCLOSE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_fclose';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  "FCLOSE_ALL"()
	SPECIFIC UTL_FILE_FCLOSE_ALL
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_fclose_all';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  "FFLUSH"(FILE "SYSIBMADM"."UTL_FILE"."FILE_TYPE")
	SPECIFIC UTL_FILE_FFLUSH
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_fflush';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  "GET_LINE"(FILE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		OUT BUFFER VARCHAR(32672))
	SPECIFIC UTL_FILE_GET_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_get_line';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  "PUT"(FILE "SYSIBMADM"."UTL_FILE"."FILE_TYPE",
		BUFFER VARCHAR(32672))
	SPECIFIC UTL_FILE_PUT
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_file_put';

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FCOPY(location VARCHAR(128), filename VARCHAR(255), dest_dir VARCHAR(128), dest_file VARCHAR(255))       SPECIFIC UTL_FILE_FCOPY_2       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.FCOPY(location, filename, dest_dir, dest_file, 1, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FCOPY(location VARCHAR(128), filename VARCHAR(255), dest_dir VARCHAR(128), dest_file VARCHAR(255), start_line INTEGER)       SPECIFIC UTL_FILE_FCOPY_3       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.FCOPY(location, filename, dest_dir, dest_file, start_line, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FCOPY(location VARCHAR(128), filename VARCHAR(255), dest_dir VARCHAR(128), dest_file VARCHAR(255), start_line INTEGER, end_line INTEGER)       SPECIFIC UTL_FILE_FCOPY       READS SQL DATA       LANGUAGE SQL       BEGIN         DECLARE dirPath  VARCHAR(1024) DEFAULT NULL;         DECLARE destPath VARCHAR(1024) DEFAULT NULL;                 CALL UTL_DIR.GET_DIRECTORY_PATH (location, dirPath);         CALL UTL_DIR.GET_DIRECTORY_PATH (dest_dir, destPath);                 IF (start_line < 1) THEN           SET start_line = 1;         END IF;                 IF (end_line < 1) THEN           SET end_line = NULL;         END IF;                 CALL UTL_FILE.imp_FCOPY(dirPath, filename, destPath, dest_file, start_line, end_line);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FREMOVE(location VARCHAR(128), filename VARCHAR(255))       SPECIFIC UTL_FILE_FREMOVE       READS SQL DATA       LANGUAGE SQL       BEGIN         DECLARE dirPath VARCHAR(1024) DEFAULT NULL;                 CALL UTL_DIR.GET_DIRECTORY_PATH(location, dirPath);         CALL UTL_FILE.imp_FREMOVE(dirPath, filename);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FRENAME(location VARCHAR(1024), file_name VARCHAR(255), dest_dir VARCHAR(1024), dest_file VARCHAR(255))       SPECIFIC UTL_FILE_FRENAME_2       LANGUAGE SQL       BEGIN         CALL UTL_FILE.FRENAME(location, file_name, dest_dir, dest_file, FALSE );       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  FRENAME(location VARCHAR(128), filename VARCHAR(255), dest_dir VARCHAR(128), dest_file VARCHAR(255), overwrite BOOLEAN)       SPECIFIC UTL_FILE_FRENAME       READS SQL DATA       LANGUAGE SQL       BEGIN         DECLARE dirPath  VARCHAR(1024) DEFAULT NULL;         DECLARE destPath VARCHAR(1024) DEFAULT NULL;                 CALL UTL_DIR.GET_DIRECTORY_PATH (location, dirPath);         CALL UTL_DIR.GET_DIRECTORY_PATH (dest_dir, destPath);                 CALL UTL_FILE.imp_FRENAME(dirPath, filename, destPath, dest_file, CASE overwrite WHEN true THEN 1 ELSE 0 END );       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  NEW_LINE(file UTL_FILE.FILE_TYPE)       SPECIFIC UTL_FILE_NEW_LINE       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_NEW_LINE(file, 1);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  NEW_LINE(file UTL_FILE.FILE_TYPE, lines BIGINT)       SPECIFIC UTL_FILE_NEW_LINE_2       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_NEW_LINE(file, lines);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672))       SPECIFIC UTL_FILE_PUTF       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 0, NULL, NULL, NULL, NULL, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672), arg1 VARCHAR(1024))       SPECIFIC UTL_FILE_PUTF_2       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 1, arg1, NULL, NULL, NULL, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672), arg1 VARCHAR(1024), arg2 VARCHAR(1024))       SPECIFIC UTL_FILE_PUTF_3       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 2, arg1, arg2, NULL, NULL, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672), arg1 VARCHAR(1024), arg2 VARCHAR(1024), arg3 VARCHAR(1024))       SPECIFIC UTL_FILE_PUTF_4       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 3, arg1, arg2, arg3, NULL, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672), arg1 VARCHAR(1024), arg2 VARCHAR(1024), arg3 VARCHAR(1024), arg4 VARCHAR(1024))       SPECIFIC UTL_FILE_PUTF_5       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 4, arg1, arg2, arg3, arg4, NULL);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUTF(file UTL_FILE.FILE_TYPE, format VARCHAR(32672), arg1 VARCHAR(1024), arg2 VARCHAR(1024), arg3 VARCHAR(1024), arg4 VARCHAR(1024), arg5 VARCHAR(1024))       SPECIFIC UTL_FILE_PUTF_6       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUTF(file, format, 5, arg1, arg2, arg3, arg4, arg5);       END;

ALTER MODULE "SYSIBMADM"."UTL_FILE" PUBLISH
	PROCEDURE  PUT_LINE(file UTL_FILE.FILE_TYPE, buffer VARCHAR(32672))       SPECIFIC UTL_FILE_PUT_LINE       READS SQL DATA       LANGUAGE SQL       BEGIN         CALL UTL_FILE.imp_PUT_LINE(file, buffer);       END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  SPLIT(IN list VARCHAR(32672), OUT tablen INTEGER, OUT tab DBMS_UTILITY.LNAME_ARRAY, OUT rc INTEGER)       SPECIFIC UTL_MAIL_SPLIT       LANGUAGE SQL       BEGIN         DECLARE currentChar CHAR(1);         DECLARE len         INTEGER;         DECLARE pos         INTEGER       DEFAULT 1;         DECLARE token       VARCHAR(1024) DEFAULT '';         DECLARE state       SMALLINT;         DECLARE delimiter   SMALLINT;         DECLARE endQuoteLoc INTEGER;                 SET rc = 0;         SET tablen = 0;         SET state = UTL_MAIL.STATE_START;         SET len = LENGTH(list) + 1;                 WHILE (pos < len) DO           SET currentChar = SUBSTR(list, pos, 1);           SET pos = pos + 1;           CASE             WHEN (currentChar = '"') THEN               /* We have found starting-QUOTE, find corresponding ending-QUOTE. And if ending-QUOTE is not found, */               /* return with an error. */               SET endQuoteLoc = LOCATE('"', list, pos);                       IF (endQuoteLoc = 0) THEN                 /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -1;                 RETURN;               ELSE                 /* Extract the string starting from start-of-QUOTE upto end-of-QUOTE. */                 SET token = SUBSTR(list, pos, endQuoteLoc - pos);                 SET pos = endQuoteLoc + 1;                 SET state = UTL_MAIL.STATE_QUOTE_END;               END IF;                     WHEN ((currentChar = '.') OR (currentChar = '@')) THEN               IF ((state = UTL_MAIL.STATE_START) OR (state = UTL_MAIL.STATE_UNDERSCORE)) THEN                 /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -2;                 RETURN;               END IF;               SET state = UTL_MAIL.STATE_START;               SET token = token || currentChar;                     WHEN (currentChar = ',') THEN               IF (state = UTL_MAIL.STATE_START) THEN                  /* First character found in input string is ',' which is an error case */                 /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -3;                 RETURN;               ELSE                 /* Valid delimiter ',' found. Increment the tablen, copy the token into tab array and */                 /* reset the state machine. */                 SET tablen = tablen + 1;                 SET tab[tablen] = token;                 SET token = '';                 SET state = UTL_MAIL.STATE_START;               END IF;                     WHEN (currentChar = '_') THEN               IF (state = UTL_MAIL.STATE_START) THEN                 SET state = UTL_MAIL.STATE_UNDERSCORE;               ELSEIF (state = UTL_MAIL.STATE_QUOTE_END) THEN                  /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -4;                 RETURN;               END IF;               SET token = token || currentChar;                     WHEN (currentChar = ' ') THEN               IF ((state = UTL_MAIL.STATE_STRING_START) OR (state = UTL_MAIL.STATE_QUOTE_END)) THEN                 SET state = UTL_MAIL.STATE_SPACE_AT_END;               ELSEIF (state = UTL_MAIL.STATE_UNDERSCORE) THEN                  /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'invalid character'; */                 SET rc = -4;                 RETURN;               END IF;               SET token = token || currentChar;                     WHEN (((currentChar >= 'A') AND (currentChar <= 'Z'))                   OR ((currentChar >= 'a') AND (currentChar <= 'z'))) THEN               IF ((state = UTL_MAIL.STATE_START) OR (state = UTL_MAIL.STATE_UNDERSCORE)) THEN                 SET state = UTL_MAIL.STATE_STRING_START;               ELSEIF ((state = UTL_MAIL.STATE_SPACE_AT_END) OR (state = UTL_MAIL.STATE_QUOTE_END)) THEN                 /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -5;                 RETURN;               END IF;               SET token = token || currentChar;                     WHEN ((currentChar >= '0') AND (currentChar <= '9')) THEN                IF (state != UTL_MAIL.STATE_STRING_START) THEN                 /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */                 SET rc = -6;                 RETURN;               END IF;               SET token = token || currentChar;                     ELSE               SET token = token || currentChar;           END CASE;         END WHILE;                 IF (state = UTL_MAIL.STATE_START) THEN           /* SIGNAL SQLSTATE '21560' SET MESSAGE_TEXT = 'missing identifier'; */           SET rc = -7;           RETURN;         ELSE           SET tablen = tablen + 1;           SET tab[tablen] = token;         END IF;       END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_ALL_RECIPIENTS(INOUT conn UTL_SMTP.connection, IN sender VARCHAR(256), INOUT recipientAddresses VARCHAR(32672), INOUT ccAddresses VARCHAR(32672),  INOUT bccAddresses VARCHAR(32672))       SPECIFIC UTL_MAIL_IMP_ADD_ALL_RECIPIENTS       LANGUAGE SQL     BEGIN       DECLARE messageHeader VARCHAR(32672);             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             SET messageHeader = 'From: ' || sender || conn.private_newline;             IF (recipientAddresses IS NOT NULL) THEN         CALL UTL_MAIL.imp_ADD_RECIPIENTS(conn, recipientAddresses, messageHeader, 'To');       END IF;             IF (ccAddresses IS NOT NULL) THEN         CALL UTL_MAIL.imp_ADD_RECIPIENTS(conn, ccAddresses, messageHeader, 'Cc');       END IF;             IF (bccAddresses IS NOT NULL) THEN         CALL UTL_MAIL.imp_ADD_RECIPIENTS(conn, bccAddresses, messageHeader, 'Bcc');       END IF;             CALL UTL_SMTP.OPEN_DATA(conn);             CALL UTL_SMTP.WRITE_DATA(conn, messageHeader);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_BOUNDARY_TEXT(IN conn UTL_SMTP.connection, IN boundaryText VARCHAR(65))       SPECIFIC UTL_MAIL_IMP_ADD_BOUNDARY_TEXT       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);       CALL UTL_SMTP.WRITE_DATA(conn, '--');       CALL UTL_SMTP.WRITE_DATA(conn, boundaryText);       CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_BOUNDARY_TEXT_AT_END(INOUT conn UTL_SMTP.connection, IN boundaryText VARCHAR(65))       SPECIFIC UTL_MAIL_IMP_ADD_BOUNDARY_TEXT_AT_END       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);       CALL UTL_SMTP.WRITE_DATA(conn, '--');       CALL UTL_SMTP.WRITE_DATA(conn, boundaryText);       CALL UTL_SMTP.WRITE_DATA(conn, '--');       CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_CONTENT_DISPOSITION(INOUT conn UTL_SMTP.connection, IN att_inline BOOLEAN, IN att_filename VARCHAR(1024))       SPECIFIC UTL_MAIL_IMP_ADD_CONTENT_DISPOSITION       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF (att_inline = TRUE) THEN         CALL UTL_SMTP.WRITE_DATA(conn, 'Content-Disposition: inline');         CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);       ELSE         CALL UTL_SMTP.WRITE_DATA(conn, 'Content-Disposition: attachment; filename="');         IF (att_filename IS NOT NULL) THEN            CALL UTL_SMTP.WRITE_DATA(conn, att_filename);         END IF;         CALL UTL_SMTP.WRITE_DATA(conn, '"');         CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_CONTENT_TRANSFER_ENCODING(INOUT conn UTL_SMTP.connection, IN encoding VARCHAR(1024))       SPECIFIC UTL_MAIL_IMP_ADD_CONTENT_TRANSFER_ENCODING       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_SMTP.WRITE_DATA(conn, 'Content-Transfer-Encoding: ');       CALL UTL_SMTP.WRITE_DATA(conn, encoding);       CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_CONTENT_TYPE(INOUT conn UTL_SMTP.connection, IN mime_type VARCHAR(1024))       SPECIFIC UTL_MAIL_IMP_ADD_CONTENT_TYPE       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF mime_type IS NULL THEN         SET mime_type = ' ';       END IF;             CALL UTL_SMTP.WRITE_DATA(conn, 'Content-Type: ');       CALL UTL_SMTP.WRITE_DATA(conn, mime_type);       CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_MIME(INOUT conn UTL_SMTP.connection)       SPECIFIC UTL_MAIL_IMP_ADD_MIME       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_SMTP.WRITE_DATA(conn, 'MIME-Version: 1.0');       CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_PRIORITY(INOUT conn UTL_SMTP.connection, IN priority INTEGER)       SPECIFIC UTL_MAIL_IMP_ADD_PRIORITY       LANGUAGE SQL       BEGIN         DECLARE priorityText VARCHAR(256);         DECLARE EXIT HANDLER FOR SQLEXCEPTION         BEGIN           IF (conn.private_sd IS NOT NULL) THEN             CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);             SET conn.private_sd = NULL;           END IF;           RESIGNAL;         END;                 SET priorityText = '';                 IF (priority = 1)  THEN           SET priorityText = priorityText || 'Priority: urgent' || conn.private_newline || 'Importance: high' || conn.private_newline;         ELSEIF (priority = 2) THEN           SET priorityText = priorityText || 'Priority: non-urgent' || conn.private_newline || 'Importance: low' || conn.private_newline;         ELSE           SET priorityText = priorityText || 'Priority: normal' || conn.private_newline || 'Importance: normal' || conn.private_newline;         END IF;                 CALL UTL_SMTP.WRITE_DATA(conn, priorityText);       END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_RECIPIENTS(INOUT conn UTL_SMTP.connection, INOUT commaSeperatedAddresses VARCHAR(32672), INOUT messageHeader VARCHAR(32672), IN typeOfCopy VARCHAR(3))       SPECIFIC UTL_MAIL_IMP_ADD_RECIPIENTS       LANGUAGE SQL     BEGIN       DECLARE moreAddressesFollow       INTEGER;       DECLARE seperatedAddress          VARCHAR(256);             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             ADD_RECIPIENTS: LOOP         CALL UTL_MAIL.imp_SEPARATE_ADDRESS(commaSeperatedAddresses, seperatedAddress, moreAddressesFollow);               CALL UTL_SMTP.RCPT(conn, seperatedAddress, NULL);               SET messageHeader = messageHeader || typeOfCopy || ': ' || seperatedAddress || conn.private_newline;               IF (moreAddressesFollow = 0) THEN           LEAVE ADD_RECIPIENTS;         END IF;       END LOOP;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_ADD_SUBJECT(INOUT conn UTL_SMTP.connection, IN subject VARCHAR(32600))       SPECIFIC UTL_MAIL_IMP_ADD_SUBJECT       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF (subject IS NOT NULL) THEN         CALL UTL_SMTP.WRITE_DATA(conn, 'Subject: ');         CALL UTL_MAIL.imp_FOLD_AND_WRITE_DATA(conn, subject);         CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_DISCONNECT(IN private_sd INTEGER)       SPECIFIC UTL_MAIL_IMP_DISCONNECT       LANGUAGE SQL     BEGIN       DECLARE tcpConn  UTL_TCP.connection;             SET tcpConn.remote_host = NULL;       SET tcpConn.remote_port = 0;       SET tcpConn.newline     = NULL;       SET tcpConn.tx_timeout  = 0;       SET tcpConn.private_sd  = private_sd;             CALL UTL_TCP.CLOSE_CONNECTION(tcpConn);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_FOLD_AND_WRITE_DATA(INOUT conn UTL_SMTP.connection, IN data VARCHAR(32672))       SPECIFIC UTL_MAIL_IMP_FOLD_AND_WRITE_DATA       LANGUAGE SQL     BEGIN       DECLARE maxLineLength INTEGER DEFAULT 78;       DECLARE startFrom     INTEGER DEFAULT 1;       DECLARE lastSpacePos  INTEGER DEFAULT 0;       DECLARE startedFrom   INTEGER DEFAULT 1;       DECLARE dataLength    INTEGER;       DECLARE sub           CHARACTER(1);             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             SET dataLength = LENGTH(data);             SUB_LOOP: LOOP         SET sub = SUBSTR(data, startFrom, 1);               IF (sub = ' ' OR sub = '	') THEN           SET lastSpacePos = startFrom;         END IF;               IF (((startFrom - startedFrom) >= maxLineLength) AND (lastSpacePos > 0)) THEN           CALL UTL_SMTP.WRITE_DATA(conn, SUBSTR(data, startedFrom, lastSpacePos - startedFrom));           CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);                 SET startedFrom  = lastSpacePos;           SET lastSpacePos = 0;         END IF;               SET startFrom = startFrom + 1;               IF (startFrom > dataLength) THEN           CALL UTL_SMTP.WRITE_DATA(conn, SUBSTR(data, startedFrom, dataLength - startedFrom + 1));           LEAVE SUB_LOOP;         END IF;             END LOOP;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_GENERATE_BOUNDARY_TEXT(OUT returnValue VARCHAR(65) )       SPECIFIC UTL_MAIL_IMP_GENERATE_BOUNDARY_TEXT       LANGUAGE SQL     BEGIN       DECLARE boundaryText VARCHAR(100);       DECLARE tempText     VARCHAR(100);       DECLARE textLength   INTEGER;       DECLARE tempLength   INTEGER;             SET textLength = 0;       SET boundaryText = '';             GEN_TEXT: LOOP       SET tempText = VARCHAR( RAND() );   /* returns double precision floating point whose precision is 53 digits */                                           /* but since the value will be between 0 and 1 and will be in  */                                           /* scientific notation therefore 100 is a safe length */       SET tempLength = LENGTH(tempText);  /* will return the actual length of the string returned usually < 20 */       IF (tempLength < 6) THEN            /* e.g. 4.58640876439698E-1 The first two and last three and  */                                           /* at least one in between */         ITERATE GEN_TEXT;       END IF;             SET tempText = SUBSTR( tempText, 3, tempLength-2-3);   /* Leave first 2 and last 3 characters */       SET tempLength = LENGTH(tempText);       SET boundaryText = boundaryText || tempText;       SET textLength = textLength + tempLength;       IF (textLength > 65) THEN         SET returnValue = SUBSTR(boundaryText, 1, 65);         LEAVE GEN_TEXT;       END IF;       END LOOP;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_PERFORM_ATTACHMENT_TASKS(INOUT conn UTL_SMTP.connection, IN boundaryText VARCHAR(65), IN att_mime_type VARCHAR(1024), IN att_inline BOOLEAN, IN att_filename VARCHAR(1024) )       SPECIFIC UTL_MAIL_IMP_PERFORM_ATTACHMENT_TASKS       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_MAIL.imp_ADD_BOUNDARY_TEXT(conn, boundaryText);             CALL UTL_MAIL.imp_ADD_CONTENT_TYPE(conn, att_mime_type);             CALL UTL_MAIL.imp_ADD_CONTENT_DISPOSITION(conn, att_inline, att_filename);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_PERFORM_FINAL_TASKS(INOUT conn UTL_SMTP.connection)       SPECIFIC UTL_MAIL_IMP_PERFORM_FINAL_TASKS       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_SMTP.CLOSE_DATA(conn);       CALL UTL_SMTP.QUIT(conn);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_PERFORM_INITIAL_TASKS(OUT conn UTL_SMTP.connection, IN sender VARCHAR(256), IN recipients VARCHAR(32672), IN cc VARCHAR(32672), IN bcc VARCHAR(32672), IN subject VARCHAR(32672), IN priority INTEGER)       SPECIFIC UTL_MAIL_IMP_PERFORM_INITIAL_TASKS       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_MAIL.imp_PREPARE(sender, conn);       CALL UTL_MAIL.imp_ADD_ALL_RECIPIENTS(conn, sender, recipients, cc, bcc);       CALL UTL_MAIL.imp_ADD_SUBJECT(conn, subject);       CALL UTL_MAIL.imp_ADD_MIME(conn);       CALL UTL_MAIL.imp_ADD_PRIORITY(conn, priority);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_PERFORM_PRE_ATTACHMENT_TASKS(INOUT conn UTL_SMTP.connection, OUT boundaryText VARCHAR(65), IN mime_type VARCHAR(1024))       SPECIFIC UTL_MAIL_IMP_PERFORM_PRE_ATTACHMENT_TASKS       LANGUAGE SQL     BEGIN       DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             CALL UTL_MAIL.imp_GENERATE_BOUNDARY_TEXT(boundaryText);             CALL UTL_MAIL.imp_ADD_CONTENT_TYPE(conn, 'multipart/mixed; boundary="' || boundaryText || '"');             CALL UTL_MAIL.imp_ADD_BOUNDARY_TEXT(conn, boundaryText);             CALL UTL_MAIL.imp_ADD_CONTENT_TYPE(conn, mime_type);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_PREPARE(IN sender VARCHAR(256), OUT conn UTL_SMTP.connection)       SPECIFIC UTL_MAIL_IMP_PREPARE       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;       DECLARE rc INTEGER DEFAULT 0;       DECLARE smtpServerList VARCHAR(255);       DECLARE serverName VARCHAR(255);       DECLARE port VARCHAR(255);       DECLARE servers DBMS_UTILITY.LNAME_ARRAY;       DECLARE i INTEGER DEFAULT 1;       DECLARE numServers INTEGER DEFAULT 0;       DECLARE colonPos INTEGER;       DECLARE SQLSTATE CHAR(5);       DECLARE SQLSTATE1 CHAR(5);       DECLARE continue HANDLER FOR SQLSTATE '22018' SET SQLSTATE1 = SQLSTATE;             /* If module SMTP server value is not set then */       /*   Get the SMTP server from DB CFG           */       IF UTL_MAIL.SMTP_SERVER IS NULL THEN         /* There are multiple rows in MPP, so we pick the value from the partition with the smallest node number */         SELECT STRIP(value) INTO smtpServerList FROM SYSIBMADM.DBCFG WHERE name = 'smtp_server' ORDER BY DBPARTITIONNUM FETCH FIRST 1 ROW ONLY;         IF smtpServerList IS NULL THEN           SET smtpServerList = '';         END IF;       ELSE         SET smtpServerList = STRIP(UTL_MAIL.SMTP_SERVER);       END IF;             IF length( smtpServerList ) <> 0 THEN         CALL SPLIT( smtpServerList, numServers, servers, rc );         IF rc <> 0 THEN           IF length( smtpServerList ) > 70 THEN             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -1336, LEFT( smtpServerList, 70 ) );           ELSE             CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -1336, smtpServerList );           END IF;         END IF;       ELSE         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -1336, NULL );       END IF;             CONNECT_ATTEMPT: WHILE i <= numServers DO         SET colonPos = LOCATE( ':', servers[i] );         IF colonPos < length( servers[i] ) THEN           SET serverName = SUBSTR( servers[i], 1, colonPos - 1 );           SET port = CAST( SUBSTR( servers[i], colonPos + 1 ) AS INTEGER );           IF SQLSTATE1 = '22018' THEN             SET serverName = servers[i];             SET port = DEFAULT_PORT;             SET SQLSTATE1 = '00000';           END IF;         ELSE           SET serverName = servers[i];           SET port = DEFAULT_PORT;         END IF;         BEGIN           CALL UTL_SMTP.OPEN_CONNECTION(serverName, port, conn, TIMEOUT, reply);           IF reply.code < 400 THEN             /* Connected */             LEAVE CONNECT_ATTEMPT;           ELSEIF i = numServers THEN             SET conn.private_sd = NULL;             /* SIGNAL SQLSTATE 'XXXXX' SET MESSAGE_TEXT = 'Unable to connect to the remote host'; */             IF length( smtpServerList ) > 70 THEN               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -1336, LEFT( smtpServerList, 70 ) );             ELSE               CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -1336, smtpServerList );             END IF;           END IF;         END;         SET i = i + 1;       END WHILE;             CALL UTL_SMTP.HELO(conn, 'localhost');             CALL UTL_SMTP.MAIL(conn, sender, NULL);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" ADD
	PROCEDURE  imp_SEPARATE_ADDRESS(INOUT commaSeparatedAddresses VARCHAR(32672), OUT separatedAddress VARCHAR(256), OUT moreAddressesFollow INTEGER)       SPECIFIC UTL_MAIL_IMP_SEPARATE_ADDRESS       LANGUAGE SQL       BEGIN         DECLARE commaSeperatedAddressLength INTEGER;         DECLARE quoteRunning                INTEGER DEFAULT 0;         DECLARE index                       INTEGER DEFAULT 1;                 SET commaSeperatedAddressLength = LENGTH(commaSeparatedAddresses);                 L1:  WHILE (index <= commaSeperatedAddressLength) DO           IF SUBSTR(commaSeparatedAddresses, index, 1) = '' THEN             IF index != commaSeperatedAddressLength AND SUBSTR(commaSeparatedAddresses, index + 1, 1) = '"' AND  quoteRunning = 1 THEN               SET index = index + 2 ;               ITERATE L1;             END IF;           ELSEIF SUBSTR(commaSeparatedAddresses, index, 1) = '"' THEN             IF quoteRunning = 0 THEN               SET quoteRunning = 1;             ELSE               SET quoteRunning  = 0;             END IF;           ELSEIF SUBSTR(commaSeparatedAddresses, index, 1) = ',' AND quoteRunning = 0 THEN             IF index = 1 THEN                   SET separatedAddress = '';             ELSE               SET separatedAddress = SUBSTR(commaSeparatedAddresses, 1, index - 1);             END IF;             IF index != commaSeperatedAddressLength THEN               SET moreAddressesFollow = 1;               SET commaSeparatedAddresses = SUBSTR(commaSeparatedAddresses, index + 1);             ELSE               SET moreAddressesFollow = 0;             END IF;             RETURN;           END IF;           SET index = index + 1;         END WHILE;                 SET separatedAddress = commaSeparatedAddresses;         SET moreAddressesFollow = 0;               END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" PUBLISH
	PROCEDURE  SEND(IN sender VARCHAR(256), IN recipients VARCHAR(32672), IN cc VARCHAR(32672) DEFAULT NULL, IN bcc VARCHAR(32672) DEFAULT NULL, IN subject VARCHAR(32672) DEFAULT NULL, IN message VARCHAR(32672) DEFAULT NULL, IN mime_type VARCHAR(1024) DEFAULT 'text/plain; charset=us-ascii', IN priority INTEGER DEFAULT 3)       SPECIFIC UTL_MAIL_SEND       LANGUAGE SQL     BEGIN       DECLARE conn  UTL_SMTP.connection;       DECLARE reply UTL_SMTP.reply;             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF (sender IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_MAIL.SEND', 'SENDER' );       ELSEIF (recipients IS NULL) AND (cc IS NULL) AND (bcc IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'UTL_MAIL.SEND', 'RECIPIENTS' );       END IF;             CALL UTL_MAIL.imp_PERFORM_INITIAL_TASKS(conn, sender, recipients, cc, bcc, subject, priority);             CALL UTL_MAIL.imp_ADD_CONTENT_TYPE(conn, mime_type);             IF (UTL_MAIL.foldMessageBody = TRUE) THEN         CALL UTL_MAIL.imp_FOLD_AND_WRITE_DATA(conn, message);       ELSE         CALL UTL_SMTP.WRITE_DATA(conn, message);       END IF;             CALL UTL_MAIL.imp_PERFORM_FINAL_TASKS(conn);     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" PUBLISH
	PROCEDURE  SEND_ATTACH_RAW(IN sender VARCHAR(256), IN recipients VARCHAR(32672), IN cc VARCHAR(32672) DEFAULT NULL, IN bcc VARCHAR(32672) DEFAULT NULL, IN subject VARCHAR(32672) DEFAULT NULL, IN message VARCHAR(32672) DEFAULT NULL, IN mime_type VARCHAR(1024) DEFAULT 'text/plain; charset=us-ascii', IN priority INTEGER DEFAULT 3, IN attachment BLOB(10M) DEFAULT NULL, IN att_inline BOOLEAN DEFAULT TRUE, IN att_mime_type VARCHAR(1024) DEFAULT 'application/octet', IN att_filename VARCHAR(512) DEFAULT NULL)       SPECIFIC UTL_MAIL_SEND_ATTACH_RAW       LANGUAGE SQL     BEGIN       DECLARE conn                UTL_SMTP.connection;       DECLARE reply               UTL_SMTP.reply;       DECLARE boundaryText        VARCHAR(65);       DECLARE encodedAttachment   BLOB(15M);             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF (sender IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_MAIL.SEND_ATTACH_RAW', 'SENDER' );       ELSEIF (recipients IS NULL) AND (cc IS NULL) AND (bcc IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'UTL_MAIL.SEND_ATTACH_RAW', 'RECIPIENTS' );       END IF;             IF (attachment IS NOT NULL AND LENGTH(attachment) != 0) THEN         CALL UTL_ENCODE.BASE64_ENCODE(attachment, encodedAttachment);                 CALL UTL_MAIL.imp_PERFORM_INITIAL_TASKS(conn, sender , recipients, cc, bcc, subject, priority);                 CALL UTL_MAIL.imp_PERFORM_PRE_ATTACHMENT_TASKS(conn, boundaryText, mime_type);                 CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);         IF (UTL_MAIL.foldMessageBody = TRUE) THEN           CALL UTL_MAIL.imp_FOLD_AND_WRITE_DATA(conn, message);         ELSE           CALL UTL_SMTP.WRITE_DATA(conn, message);         END IF;         CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);                 CALL UTL_MAIL.imp_PERFORM_ATTACHMENT_TASKS(conn, boundaryText, att_mime_type, att_inline, att_filename);                 CALL UTL_MAIL.imp_ADD_CONTENT_TRANSFER_ENCODING(conn, 'base64');                 CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);         CALL UTL_SMTP.WRITE_RAW_DATA(conn, encodedAttachment);                 CALL UTL_MAIL.imp_ADD_BOUNDARY_TEXT_AT_END(conn, boundaryText);                 CALL UTL_MAIL.imp_PERFORM_FINAL_TASKS(conn);       ELSE           CALL UTL_MAIL.SEND(sender, recipients, cc, bcc, subject, message, mime_type, priority);       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_MAIL" PUBLISH
	PROCEDURE  SEND_ATTACH_VARCHAR2(IN sender VARCHAR(256), IN recipients VARCHAR(32672), IN cc VARCHAR(32672) DEFAULT NULL, IN bcc VARCHAR(32672) DEFAULT NULL, IN subject VARCHAR(32672) DEFAULT NULL, IN message VARCHAR(32672) DEFAULT NULL, IN mime_type VARCHAR(1024) DEFAULT 'text/plain; charset=us-ascii', IN priority INTEGER DEFAULT 3, IN attachment VARCHAR(32000) DEFAULT NULL, IN att_inline BOOLEAN DEFAULT TRUE, IN att_mime_type VARCHAR(1024) DEFAULT 'text/plain; charset=us-ascii', IN att_filename VARCHAR(512) DEFAULT NULL)       SPECIFIC UTL_MAIL_SEND_ATTACH_VARCHAR2       LANGUAGE SQL     BEGIN       DECLARE conn                UTL_SMTP.connection;       DECLARE reply               UTL_SMTP.reply;       DECLARE boundaryText        VARCHAR(65);             DECLARE EXIT HANDLER FOR SQLEXCEPTION       BEGIN         IF (conn.private_sd IS NOT NULL) THEN           CALL UTL_MAIL.imp_DISCONNECT(conn.private_sd);           SET conn.private_sd = NULL;         END IF;         RESIGNAL;       END;             IF (sender IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_MAIL.SEND_ATTACH_RAW', 'SENDER' );       ELSEIF (recipients IS NULL) AND (cc IS NULL) AND (bcc IS NULL) THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '2', 'UTL_MAIL.SEND_ATTACH_RAW', 'RECIPIENTS' );       END IF;             IF (attachment IS NOT NULL AND LENGTH(attachment) != 0) THEN         CALL UTL_MAIL.imp_PERFORM_INITIAL_TASKS(conn, sender , recipients, cc, bcc, subject, priority);                 CALL UTL_MAIL.imp_PERFORM_PRE_ATTACHMENT_TASKS(conn, boundaryText, mime_type);                 CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);         IF (UTL_MAIL.foldMessageBody = TRUE) THEN           CALL UTL_MAIL.imp_FOLD_AND_WRITE_DATA(conn, message);         ELSE           CALL UTL_SMTP.WRITE_DATA(conn, message);         END IF;         CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);                 CALL UTL_MAIL.imp_PERFORM_ATTACHMENT_TASKS(conn, boundaryText, att_mime_type, att_inline, att_filename);                 CALL UTL_SMTP.WRITE_DATA(conn, conn.private_newline);         CALL UTL_SMTP.WRITE_DATA(conn, attachment);                 CALL UTL_MAIL.imp_ADD_BOUNDARY_TEXT_AT_END(conn, boundaryText);                 CALL UTL_MAIL.imp_PERFORM_FINAL_TASKS(conn);       ELSE           CALL UTL_MAIL.SEND(sender, recipients, cc, bcc, subject, message, mime_type, priority);       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	PROCEDURE  IMP_COMMAND2(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), IN arg VARCHAR(32672), IN routineName VARCHAR(257))       SPECIFIC UTL_SMTP_IMP_COMMAND2       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             CALL UTL_SMTP.imp_COMMAND(c, cmd, arg, reply, 1, routineName);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	PROCEDURE  imp_COMMAND(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), IN arg VARCHAR(32672), OUT reply UTL_SMTP.reply, IN raiseException INTEGER, routineName VARCHAR(257))       SPECIFIC UTL_SMTP_IMP_COMMAND       LANGUAGE SQL     BEGIN       DECLARE tcpConn        UTL_TCP.connection;       DECLARE strReply       VARCHAR(512);       DECLARE returnValue    INTEGER;       DECLARE strSpace       VARCHAR(1);       DECLARE isLastReplyLine  BOOLEAN;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, routineName);             IF arg IS NOT NULL THEN         CALL UTL_TCP.WRITE_TEXT(tcpConn, cmd, LENGTH(cmd), returnValue);         SET strSpace = ' ';         CALL UTL_TCP.WRITE_TEXT(tcpConn, strSpace, LENGTH(strSpace), returnValue);         CALL UTL_TCP.WRITE_LINE(tcpConn, arg, returnValue);       ELSE         CALL UTL_TCP.WRITE_LINE(tcpConn, cmd, returnValue);       END IF;             READ_LOOP: LOOP         CALL UTL_TCP.READ_LINE(tcpConn, strReply, returnValue);         CALL UTL_SMTP.imp_convertReplyToStruct(strReply, reply, isLastReplyLine);         IF (isLastReplyLine = TRUE) THEN           LEAVE READ_LOOP;         END IF;       END LOOP;             IF (raiseException = 1) THEN         IF ( (reply.code >= 400) AND (reply.code < 500) ) THEN           /* SIGNAL SQLSTATE '29278' SET MESSAGE_TEXT = strReply; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20514, reply.code, '5UA0E' );         ELSEIF (reply.code >= 500) THEN           /* SIGNAL SQLSTATE '29279' SET MESSAGE_TEXT = strReply; */           CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20514, reply.code, '5UA0F' );         END IF;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	PROCEDURE  imp_convertReplyToStruct(IN strReply VARCHAR(512), OUT reply UTL_SMTP.reply, OUT isLastReplyLine BOOLEAN)       SPECIFIC UTL_SMTP_IMP_CONVERTREPLYTOSTRUCT       READS SQL DATA       LANGUAGE SQL     BEGIN       DECLARE strCode       VARCHAR(3);       DECLARE returnValue   INTEGER;             SET strCode    = SUBSTR(strReply, 1, 3);       SET reply.code = CAST(strCode AS INTEGER);       SET reply.text = SUBSTR(strReply, 5);           IF (SUBSTR(strReply, 4, 1) = '-') THEN     /* If 4th character is a dash then it is not the last line */         SET isLastReplyLine = FALSE;       ELSE         SET isLastReplyLine = TRUE;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" ADD
	PROCEDURE  imp_convertSmtpToTcpStruct(IN smtpCon UTL_SMTP.connection, OUT tcpConn UTL_TCP.connection, routineName VARCHAR(257))       SPECIFIC UTL_SMTP_IMP_CONVERTSMTPTOTCPSTRUCT       LANGUAGE SQL     BEGIN       DECLARE wa_remote_host VARCHAR(255);       DECLARE wa_remote_port INTEGER;       DECLARE wa_newline     VARCHAR(2);       DECLARE wa_tx_timeout  INTEGER;       DECLARE wa_private_sd  INTEGER;             IF smtpCon.host IS NULL OR smtpCon.port IS NULL OR smtpCon.tx_timeout IS NULL OR smtpCon.private_sd IS NULL OR smtpCon.private_newline IS NULL THEN         /* SIGNAL SQLSTATE '29261' SET MESSAGE_TEXT = 'Bad argument'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', routineName, 'C' );       END IF;             SET wa_remote_host = smtpCon.host;       SET wa_remote_port = smtpCon.port;       SET wa_newline     = smtpCon.private_newline;       SET wa_tx_timeout  = smtpCon.tx_timeout;       SET wa_private_sd  = smtpCon.private_sd;             SET tcpConn.remote_host = wa_remote_host;       SET tcpConn.remote_port = wa_remote_port;       SET tcpConn.newline     = wa_newline;       SET tcpConn.tx_timeout  = wa_tx_timeout;       SET tcpConn.private_sd  = wa_private_sd;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	FUNCTION  OPEN_CONNECTION(host VARCHAR(255), port INTEGER, tx_timeout INTEGER)       RETURNS UTL_SMTP.connection       SPECIFIC UTL_SMTP_OPEN_CONNECTION_2       LANGUAGE SQL     BEGIN       DECLARE con   UTL_SMTP.connection;       DECLARE reply UTL_SMTP.reply;             CALL UTL_SMTP.OPEN_CONNECTION(host, port, con, tx_timeout, reply);       return con;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  CLOSE_DATA(INOUT c UTL_SMTP.connection)       SPECIFIC UTL_SMTP_CLOSE_DATA       LANGUAGE SQL     BEGIN       DECLARE returnValue    INTEGER;       DECLARE tcpConn        UTL_TCP.connection;       DECLARE reply          UTL_SMTP.reply;             IF (c.private_state <> UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in CLOSE_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'CLOSE_DATA' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.CLOSE_DATA');             CALL UTL_TCP.WRITE_TEXT(tcpConn, tcpConn.newline, LENGTH(tcpConn.newline), returnValue);             CALL UTL_SMTP.IMP_COMMAND(c, '.', NULL, reply, 1, 'UTL_SMTP.CLOSE_DATA');             SET c.private_state = UTL_SMTP.STATE_CONNECTED;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  CLOSE_DATA(INOUT c UTL_SMTP.connection, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_CLOSE_DATA_2       LANGUAGE SQL     BEGIN       DECLARE returnValue    INTEGER;       DECLARE tcpConn        UTL_TCP.connection;             IF (c.private_state <> UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in CLOSE_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'CLOSE_DATA' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.CLOSE_DATA');             CALL UTL_TCP.WRITE_TEXT(tcpConn, tcpConn.newline, LENGTH(tcpConn.newline), returnValue);             CALL UTL_SMTP.IMP_COMMAND(c, '.', NULL, reply, 0, 'UTL_SMTP.CLOSE_DATA');             SET c.private_state = UTL_SMTP.STATE_CONNECTED;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  COMMAND(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), IN arg VARCHAR(32672) DEFAULT NULL)       SPECIFIC UTL_SMTP_COMMAND       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             CALL UTL_SMTP.imp_COMMAND(c, cmd, arg, reply, 1, 'UTL_SMTP.COMMAND');     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  COMMAND(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), IN arg VARCHAR(32672), OUT reply UTL_SMTP.reply )       SPECIFIC UTL_SMTP_COMMAND_2       LANGUAGE SQL     BEGIN       CALL UTL_SMTP.imp_COMMAND(c, cmd, arg, reply, 0, 'UTL_SMTP.COMMAND');     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  COMMAND_REPLIES(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), IN arg VARCHAR(32672), OUT replies UTL_SMTP.replies )       SPECIFIC UTL_SMTP_COMMAND_REPLIES       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;       CALL UTL_SMTP.imp_COMMAND(c, cmd, arg, reply, 0, 'UTL_SMTP.COMMAND_REPLIES');       SET replies[1] = reply;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  COMMAND_REPLIES(INOUT c UTL_SMTP.connection, IN cmd VARCHAR(510), OUT replies UTL_SMTP.replies )       SPECIFIC UTL_SMTP_COMMAND_REPLIES_2       LANGUAGE SQL     BEGIN       CALL UTL_SMTP.COMMAND_REPLIES(c, cmd, NULL, replies);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  DATA(INOUT c UTL_SMTP.connection, IN body VARCHAR(32000))       SPECIFIC UTL_SMTP_DATA       LANGUAGE SQL     BEGIN       IF c.host IS NULL OR c.port IS NULL OR c.tx_timeout IS NULL OR c.private_sd IS NULL OR c.private_newline IS NULL THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '1', 'UTL_SMTP.DATA', 'C' );       END IF;             CALL UTL_SMTP.OPEN_DATA(c);             CALL UTL_SMTP.WRITE_DATA(c, body);             CALL UTL_SMTP.CLOSE_DATA(c);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  DATA(INOUT c UTL_SMTP.connection, IN body VARCHAR(32000), OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_DATA_2       LANGUAGE SQL     BEGIN       CALL UTL_SMTP.DATA(c, body);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  EHLO(INOUT c UTL_SMTP.connection, IN domain VARCHAR(255))       SPECIFIC UTL_SMTP_EHLO       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in EHLO'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'EHLO' );       END IF;             IF domain IS NULL THEN         SET domain = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'ehlo ' || domain, NULL, reply, 1, 'UTL_SMTP.EHLO');             IF (c.private_state = UTL_SMTP.STATE_CONNECTED) THEN         SET c.private_state = UTL_SMTP.STATE_HELO_SENT;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  EHLO(INOUT c UTL_SMTP.connection, IN domain VARCHAR(255), OUT replies UTL_SMTP.REPLIES )       SPECIFIC UTL_SMTP_EHLO_2       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in EHLO'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'EHLO' );       END IF;             IF domain IS NULL THEN         SET domain = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'ehlo ' || domain, NULL, reply, 0, 'UTL_SMTP.EHLO');       SET replies[1] = reply;             IF (c.private_state = UTL_SMTP.STATE_CONNECTED) THEN         SET c.private_state = UTL_SMTP.STATE_HELO_SENT;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  HELO(INOUT c UTL_SMTP.connection, IN domain VARCHAR(255))       SPECIFIC UTL_SMTP_HELO       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in HELO'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'HELO' );       END IF;             IF domain IS NULL THEN         SET domain = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'helo ' || domain, NULL, reply, 1, 'UTL_SMTP.HELO');             IF (c.private_state = UTL_SMTP.STATE_CONNECTED) THEN         SET c.private_state = UTL_SMTP.STATE_HELO_SENT;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  HELO(INOUT c UTL_SMTP.connection, IN domain VARCHAR(255), OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_HELO_2       LANGUAGE SQL     BEGIN       IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in HELO'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'HELO' );       END IF;             IF domain IS NULL THEN         SET domain = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'helo ' || domain, NULL, reply, 0, 'UTL_SMTP.HELO');             IF (c.private_state = UTL_SMTP.STATE_CONNECTED) THEN         SET c.private_state = UTL_SMTP.STATE_HELO_SENT;       END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  HELP(INOUT c UTL_SMTP.connection, IN command VARCHAR(510), OUT replies UTL_SMTP.REPLIES)       SPECIFIC UTL_SMTP_HELP       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF command IS NULL THEN         CALL UTL_SMTP.IMP_COMMAND(c, 'help', NULL, reply, 0, 'UTL_SMTP.HELP');       ELSE         CALL UTL_SMTP.IMP_COMMAND(c, 'help ' || command, NULL, reply, 0, 'UTL_SMTP.HELP');       END IF;       SET replies[1] = reply;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  HELP(INOUT c UTL_SMTP.connection, OUT replies UTL_SMTP.REPLIES)       SPECIFIC UTL_SMTP_HELP_2       LANGUAGE SQL     BEGIN       CALL UTL_SMTP.HELP(c, NULL, replies);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  MAIL(INOUT c UTL_SMTP.connection, IN sender VARCHAR(256), IN parameters VARCHAR(32672) DEFAULT NULL)       SPECIFIC UTL_SMTP_MAIL       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state <> UTL_SMTP.STATE_HELO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in MAIL'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'MAIL' );       END IF;             IF sender IS NULL THEN         SET sender = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'mail from: ' || sender, parameters, reply, 1, 'UTL_SMTP.MAIL');             SET c.private_state = UTL_SMTP.STATE_MAIL_FROM_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  MAIL(INOUT c UTL_SMTP.connection, IN sender VARCHAR(256), IN parameters VARCHAR(32672), OUT reply UTL_SMTP.REPLY)       SPECIFIC UTL_SMTP_MAIL_2       LANGUAGE SQL     BEGIN       IF (c.private_state <> UTL_SMTP.STATE_HELO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in MAIL'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'MAIL' );       END IF;             IF sender IS NULL THEN         SET sender = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'mail from: ' || sender, parameters, reply, 0, 'UTL_SMTP.MAIL');             SET c.private_state = UTL_SMTP.STATE_MAIL_FROM_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  NOOP(INOUT c UTL_SMTP.connection)       SPECIFIC UTL_SMTP_NOOP       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in NOOP'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'NOOP' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'noop', NULL, reply, 1, 'UTL_SMTP.NOOP');     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  NOOP(INOUT c UTL_SMTP.connection, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_NOOP_2       LANGUAGE SQL     BEGIN       IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in NOOP'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'NOOP' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'noop', NULL, reply, 0, 'UTL_SMTP.NOOP');     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  OPEN_CONNECTION(IN host VARCHAR(255), IN port INTEGER, OUT c UTL_SMTP.connection, IN tx_timeout INTEGER, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_OPEN_CONNECTION       READS SQL DATA       LANGUAGE SQL     BEGIN       DECLARE tcpCon         UTL_TCP.connection;       DECLARE newLine        VARCHAR(2);       DECLARE returnValue    INTEGER;       DECLARE wa_private_sd  INTEGER;       DECLARE strReply       VARCHAR(512);       DECLARE isLastReplyLine  BOOLEAN;           /* This definition is in accordance with  */     /* RFC 822 APPENDIX D */     /* CR = <ASCII CR, carriage return>; (13 decimal) */     /* LF = <ASCII LF, linefeed>       ; (10 decimal) */       SET newLine = CONCAT( CHR(13), CHR(10) );             CALL UTL_TCP.OPEN_CONNECTION(host, port, newLine, tx_timeout, FALSE, tcpCon);       SET wa_private_sd = tcpCon.private_sd;             IF (wa_private_sd <= 0) THEN         SET c.host            = NULL;         SET c.port            = 0;         SET c.tx_timeout      = 0;         SET c.private_sd      = wa_private_sd;         SET c.private_newline = NULL;               SET strReply = '421 Service not available';         CALL UTL_SMTP.imp_convertReplyToStruct(strReply, reply, isLastReplyLine);       ELSE         SET c.host            = host;         SET c.port            = port;         IF (tx_timeout IS NULL) THEN           SET c.tx_timeout = -1;         ELSE           SET c.tx_timeout = tx_timeout;         END IF;         SET c.private_sd      = wa_private_sd;         SET c.private_newline = newLine;               READ_LOOP: LOOP           CALL UTL_TCP.READ_LINE(tcpCon, strReply, returnValue);           CALL UTL_SMTP.imp_convertReplyToStruct(strReply, reply, isLastReplyLine);           IF (isLastReplyLine = TRUE) THEN             LEAVE READ_LOOP;           END IF;         END LOOP;               SET c.private_state = UTL_SMTP.STATE_CONNECTED;             END IF;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  OPEN_DATA(INOUT c UTL_SMTP.connection)       SPECIFIC UTL_SMTP_OPEN_DATA       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state <> UTL_SMTP.STATE_RCPT_TO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in OPEN_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'OPEN_DATA' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'data', NULL, reply, 1, 'UTL_SMTP.OPEN_DATA');             SET c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  OPEN_DATA(INOUT c UTL_SMTP.connection, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_OPEN_DATA_2       LANGUAGE SQL     BEGIN       IF (c.private_state <> UTL_SMTP.STATE_RCPT_TO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in OPEN_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'OPEN_DATA' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'data', NULL, reply, 0, 'UTL_SMTP.OPEN_DATA');             SET c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  QUIT(INOUT c UTL_SMTP.connection)       SPECIFIC UTL_SMTP_QUIT       LANGUAGE SQL     BEGIN       DECLARE tcpConn        UTL_TCP.connection;       DECLARE reply          UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in QUIT'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'QUIT' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.QUIT');             CALL UTL_SMTP.IMP_COMMAND(c, 'quit', NULL, reply, 1, 'UTL_SMTP.QUIT');             CALL UTL_TCP.CLOSE_CONNECTION(tcpConn);             SET c.host          = NULL;       SET c.port          = 0;       SET c.private_state = UTL_SMTP.STATE_INITIAL;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  QUIT(INOUT c UTL_SMTP.connection, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_QUIT_2       LANGUAGE SQL     BEGIN       DECLARE tcpConn        UTL_TCP.connection;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in QUIT'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'QUIT' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.QUIT');             CALL UTL_SMTP.IMP_COMMAND(c, 'quit', NULL, reply, 0, 'UTL_SMTP.QUIT');             CALL UTL_TCP.CLOSE_CONNECTION(tcpConn);             SET c.host          = NULL;       SET c.port          = 0;       SET c.private_state = UTL_SMTP.STATE_INITIAL;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  RCPT(INOUT c UTL_SMTP.connection, IN recipient VARCHAR(256), IN parameters VARCHAR(32672) DEFAULT NULL)       SPECIFIC UTL_SMTP_RCPT       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state <> UTL_SMTP.STATE_MAIL_FROM_SENT AND c.private_state <> UTL_SMTP.STATE_RCPT_TO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in RCPT'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'RCPT' );       END IF;             IF recipient IS NULL THEN         SET recipient = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'rcpt to: ' || recipient, parameters, reply, 1, 'UTL_SMTP.RCPT');             SET c.private_state = UTL_SMTP.STATE_RCPT_TO_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  RCPT(INOUT c UTL_SMTP.connection, IN recipient VARCHAR(256), IN parameters VARCHAR(32672), OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_RCPT_2       LANGUAGE SQL     BEGIN       IF (c.private_state <> UTL_SMTP.STATE_MAIL_FROM_SENT AND c.private_state <> UTL_SMTP.STATE_RCPT_TO_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in RCPT'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'RCPT' );       END IF;             IF recipient IS NULL THEN         SET recipient = '';       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'rcpt to: ' || recipient, parameters, reply, 0, 'UTL_SMTP.RCPT');             SET c.private_state = UTL_SMTP.STATE_RCPT_TO_SENT;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  RSET(INOUT c UTL_SMTP.connection)       SPECIFIC UTL_SMTP_RSET       LANGUAGE SQL     BEGIN       DECLARE reply UTL_SMTP.reply;             IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in RSET'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'RSET' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'rset', NULL, reply, 1, 'UTL_SMTP.RSET');             SET c.private_state = UTL_SMTP.STATE_CONNECTED;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  RSET(INOUT c UTL_SMTP.connection, OUT reply UTL_SMTP.reply)       SPECIFIC UTL_SMTP_RSET_2       LANGUAGE SQL     BEGIN       IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in RSET'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'RSET' );       END IF;             CALL UTL_SMTP.IMP_COMMAND(c, 'rset', NULL, reply, 0, 'UTL_SMTP.RSET');             SET c.private_state = UTL_SMTP.STATE_CONNECTED;     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  VRFY(INOUT c UTL_SMTP.connection, IN recipient VARCHAR(256), OUT reply UTL_SMTP.REPLY)       SPECIFIC UTL_SMTP_VRFY       LANGUAGE SQL     BEGIN       IF (c.private_state = UTL_SMTP.STATE_INITIAL OR  c.private_state = UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in VRFY'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'VRFY' );       END IF;             IF recipient IS NULL THEN         SET recipient = '';       END IF;             CALL UTL_SMTP.imp_COMMAND(c, 'vrfy ' || recipient, NULL, reply, 0, 'UTL_SMTP.VRFY');     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  WRITE_DATA(INOUT c UTL_SMTP.connection, IN data VARCHAR(32000))       SPECIFIC UTL_SMTP_WRITE_DATA       LANGUAGE SQL     BEGIN       DECLARE returnValue        INTEGER;       DECLARE tcpConn            UTL_TCP.connection;       DECLARE strToLookFor       VARCHAR(5);       DECLARE strToRelaceWith    VARCHAR(6);       DECLARE strReplacedString  VARCHAR(32672);       DECLARE strFirstThree      VARCHAR(3);             IF (c.private_state <> UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in WRITE_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'WRITE_DATA' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.WRITE_DATA' );             SET strReplacedString = data;             IF (LENGTH(data) > 2) THEN         SET strFirstThree = LEFT(data, 3);         SET strToLookFor = '.' || CHR(13) || CHR(10);                                            /* .
 */         IF (LOCATE(strToLookFor, strFirstThree) = 1) THEN         SET strReplacedString = '.' || data;                                                   /* ..
 */         ELSE         SET strToLookFor = '.' || CHR(10);                                                     /* .
 */           IF (LOCATE(strToLookFor, strFirstThree) = 1) THEN           SET strReplacedString = '.' || data;                                                 /* ..
 */           END IF;         END IF;               SET strToLookFor = CHR(10) || '.' || CHR(13);                                            /* 
.
 */         SET strToRelaceWith = CHR(10) || '..' || CHR(13);                                        /* 
..
 */         SET strReplacedString = REPLACE(strReplacedString, strToLookFor, strToRelaceWith);               SET strToLookFor = CHR(10) || '.' || CHR(10);                                            /* 
.
 */         SET strToRelaceWith = CHR(10) || '..' || CHR(10);                                        /* 
..
 */         SET strReplacedString = REPLACE(strReplacedString, strToLookFor, strToRelaceWith);       END IF;             CALL UTL_TCP.WRITE_TEXT(tcpConn, strReplacedString, LENGTH(strReplacedString), returnValue);     END;

ALTER MODULE "SYSIBMADM"."UTL_SMTP" PUBLISH
	PROCEDURE  WRITE_RAW_DATA(INOUT c UTL_SMTP.connection, IN data BLOB(15M))       SPECIFIC UTL_SMTP_WRITE_RAW_DATA       LANGUAGE SQL     BEGIN       DECLARE returnValue        INTEGER;       DECLARE tcpConn            UTL_TCP.connection;       DECLARE seqToLookFor       BLOB(5);       DECLARE seqToRelaceWith    BLOB(6);       DECLARE seqReplacedString  BLOB(20M);       DECLARE seqFirstThree      BLOB(3);             IF (c.private_state <> UTL_SMTP.STATE_OPEN_DATA_SENT) THEN         /* SIGNAL SQLSTATE '29277' SET MESSAGE_TEXT = 'Operation is invalid in WRITE_RAW_DATA'; */         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -20518, 'WRITE_RAW_DATA' );       END IF;             CALL UTL_SMTP.imp_convertSmtpToTcpStruct(c, tcpConn, 'UTL_SMTP.WRITE_RAW_DATA');             SET seqReplacedString = data;             IF (LENGTH(data) > 2) THEN         SET seqFirstThree = LEFT(data, 3);         SET seqToLookFor = BLOB( '.' || CHR(13) || CHR(10) );                                            /* .
 */         IF (LOCATE(seqToLookFor, seqFirstThree) = 1) THEN           SET seqReplacedString = BLOB( '.' ) || data;                                                   /* ..
 */         ELSE           SET seqToLookFor = BLOB('.' || CHR(10));                                                     /* .
 */           IF (LOCATE(seqToLookFor, seqFirstThree) = 1) THEN           SET seqReplacedString = BLOB('.') || data;                                                 /* ..
 */           END IF;         END IF;               SET seqToLookFor = BLOB( CHR(10) || '.' || CHR(13) );                                            /* 
.
 */         SET seqToRelaceWith = BLOB( CHR(10) || '..' || CHR(13) );                                        /* 
..
 */         SET seqReplacedString = REPLACE(seqReplacedString, seqToLookFor, seqToRelaceWith);               SET seqToLookFor = BLOB( CHR(10) || '.' || CHR(10) );                                            /* 
.
 */         SET seqToRelaceWith = BLOB( CHR(10) || '..' || CHR(10) );                                        /* 
..
 */         SET seqReplacedString = REPLACE(seqReplacedString, seqToLookFor, seqToRelaceWith);       END IF;             CALL UTL_TCP.WRITE_RAW(tcpConn, seqReplacedString, returnValue);     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" ADD
	FUNCTION  "IMP_OPEN_CONNECTION"(REMOTE_HOST VARCHAR(255),
		REMOTE_PORT INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC UTL_TCP_IMP_OPEN_CONNECTION
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."UTL_TCP" ADD
	FUNCTION  "IMP_WRITE_RAW"(PRIVATE_SD INTEGER,
		DATA BLOB(20971520),
		TX_TIMEOUT INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC UTL_TCP_IMP_WRITE_RAW
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."UTL_TCP" ADD
	FUNCTION  "IMP_WRITE_TEXT"(PRIVATE_SD INTEGER,
		DATA VARCHAR(32672),
		LEN INTEGER,
		TX_TIMEOUT INTEGER)
	RETURNS INTEGER
	LANGUAGE C
	SPECIFIC UTL_TCP_IMP_WRITE_TEXT
	PARAMETER STYLE SQL
	FENCED THREADSAFE
	NO SQL
	DISALLOW PARALLEL;

ALTER MODULE "SYSIBMADM"."UTL_TCP" ADD
	PROCEDURE  "IMP_CLOSE_CONNECTION"(PRIVATE_SD INTEGER)
	SPECIFIC UTL_TCP_IMP_CLOSE_CONNECTION
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_tcp_close_connection';

ALTER MODULE "SYSIBMADM"."UTL_TCP" ADD
	PROCEDURE  "IMP_READ_LINE"(PRIVATE_SD INTEGER,
		TX_TIMEOUT INTEGER,
		OUT DATA VARCHAR(32672),
		OUT RET_VALUE INTEGER)
	SPECIFIC UTL_TCP_IMP_READ_LINE
	NO SQL
	LANGUAGE C
	NOT FENCED
	PARAMETER STYLE SQL
	EXTERNAL NAME 'db2modlib!sqleml_utl_tcp_read_line';

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  CLOSE_CONNECTION(INOUT c UTL_TCP.connection)       SPECIFIC UTL_TCP_CLOSE_CONNECTION       LANGUAGE SQL     BEGIN       CALL UTL_TCP.imp_CLOSE_CONNECTION(c.private_sd);       SET c.remote_host = NULL;       SET c.remote_port = 0;     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  OPEN_CONNECTION(remote_host VARCHAR(255), remote_port INTEGER, newline VARCHAR(2), tx_timeout INTEGER, throwException BOOLEAN, OUT c UTL_TCP.connection)       SPECIFIC UTL_TCP_OPEN_CONNECTION       CONTAINS SQL       LANGUAGE SQL     BEGIN       DECLARE private_sd INTEGER;             /* Note: thrownException is never true with the current code,        * If this changes, we need to change UTL_TCP.IMP_OPEN_CONNECTION to        * throw the exception.        */       IF throwException = TRUE THEN         CALL SYSIBMINTERNAL.SQLEML_RAISE_ERROR( -171, '5', 'UTL_TCP.OPEN_CONNECTION', 'THROWEXCEPTION' );       END IF;             SET private_sd = UTL_TCP.imp_OPEN_CONNECTION(remote_host, remote_port);             /*       IF (private_sd < 0 AND throwException = TRUE) THEN         CASE           WHEN (private_sd = -2 )  THEN SIGNAL SQLSTATE 'XXXXX' SET MESSAGE_TEXT = 'Name to IP resolution failed';           WHEN (private_sd = -3 )  THEN SIGNAL SQLSTATE 'XXXXX' SET MESSAGE_TEXT = 'Unable to connect to the remote host';           WHEN (private_sd = -10 ) THEN SIGNAL SQLSTATE 'XXXXX' SET MESSAGE_TEXT = 'Bad argument';         END CASE;       END IF;       */             SET c.remote_host = remote_host;       SET c.remote_port = remote_port;       SET c.newline = newline;       IF (tx_timeout IS NULL) THEN         SET c.tx_timeout = -1;       ELSE         SET c.tx_timeout = tx_timeout;       END IF;       SET c.private_sd = private_sd;     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  READ_LINE(c UTL_TCP.connection, OUT data VARCHAR(32672), OUT rValue INTEGER )       SPECIFIC UTL_TCP_READ_LINE       CONTAINS SQL       LANGUAGE SQL     BEGIN       DECLARE returnValue INTEGER;             CALL UTL_TCP.imp_READ_LINE(c.private_sd, c.tx_timeout, data, returnValue);             SET rValue = returnValue;     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  WRITE_LINE(c UTL_TCP.connection, data VARCHAR(32672), OUT bytesWritten INTEGER)       SPECIFIC UTL_TCP_WRITE_LINE       LANGUAGE SQL     BEGIN       DECLARE returnValue INTEGER;             SET bytesWritten = 0;       SET returnValue = 0;             CALL UTL_TCP.WRITE_TEXT(c, data, LENGTH(data), bytesWritten);             CALL UTL_TCP.WRITE_TEXT(c, c.newline, LENGTH(c.newline), returnValue);     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  WRITE_RAW(c UTL_TCP.connection, data BLOB(20M), OUT returnValue INTEGER)       SPECIFIC UTL_TCP_WRITE_RAW       LANGUAGE SQL     BEGIN       SET returnValue = UTL_TCP.imp_WRITE_RAW(c.private_sd, data, c.tx_timeout);     END;

ALTER MODULE "SYSIBMADM"."UTL_TCP" PUBLISH
	PROCEDURE  WRITE_TEXT(c UTL_TCP.connection, data VARCHAR(32672), len INTEGER, OUT returnValue INTEGER)       SPECIFIC UTL_TCP_WRITE_TEXT       LANGUAGE SQL     BEGIN             SET returnValue = UTL_TCP.imp_WRITE_TEXT(c.private_sd, data, len, c.tx_timeout);     END;

CREATE TRIGGER "AJAY"."DO_NOT_DEL_SALES" 
	BEFORE DELETE ON "AJAY"."STAFF"
	REFERENCING  OLD AS oldstaff
	FOR EACH ROW
WHEN (oldstaff.job = 'Sales')
BEGIN ATOMIC SIGNAL SQLSTATE '75000' ('Sales staff cannot be deleted... see the DO_NOT_DEL_SALES trigger.'); END;

CREATE TRIGGER "AJAY"."MIN_SALARY" 
	BEFORE INSERT ON "AJAY"."STAFF"
	REFERENCING  NEW AS newstaff
	FOR EACH ROW
BEGIN ATOMIC SET newstaff.salary = CASE WHEN newstaff.job = 'Mgr' AND newstaff.salary < 17000.00 THEN 17000.00 WHEN newstaff.job = 'Sales' AND newstaff.salary < 14000.00 THEN 14000.00 WHEN newstaff.job = 'Clerk' AND newstaff.salary < 10000.00 THEN 10000.00 ELSE newstaff.salary END; END;

CREATE TRIGGER "SYSTOOLS"."POLICY_DR" 
	BEFORE DELETE ON "SYSTOOLS"."POLICY"
	REFERENCING  OLD AS OLD_ROW
	FOR EACH ROW
BEGIN ATOMIC    IF ( ( SELECT COUNT(*) FROM SYSTOOLS.POLICY WHERE OLD_ROW.MED = MED AND OLD_ROW.DECISION = DECISION ) = 1 ) THEN      SIGNAL SQLSTATE '85101' ('At least one policy is required.');    END IF;  END;

CREATE TRIGGER "SYSTOOLS"."POLICY_IR" 
	BEFORE INSERT ON "SYSTOOLS"."POLICY"
	REFERENCING  NEW AS NEW_ROW
	FOR EACH ROW
BEGIN ATOMIC    IF ( ( SELECT COUNT(*) FROM SYSTOOLS.POLICY WHERE NEW_ROW.MED = MED AND NEW_ROW.DECISION = DECISION ) = 1 ) THEN      SIGNAL SQLSTATE '85101' ('Only one policy is allowed.');    END IF;  END;

CREATE TRIGGER "SYSTOOLS"."POLICY_IV" 
	BEFORE INSERT ON "SYSTOOLS"."POLICY"
	REFERENCING  NEW AS N
	FOR EACH ROW
BEGIN ATOMIC    VALUES (SYSPROC.POLICY_VALIDATE(N.MED,N.POLICY));  END;

CREATE TRIGGER "SYSTOOLS"."POLICY_UV" 
	BEFORE UPDATE ON "SYSTOOLS"."POLICY"
	REFERENCING  NEW AS N
	FOR EACH ROW
BEGIN ATOMIC    VALUES (SYSPROC.POLICY_VALIDATE(N.MED,N.POLICY));  END;

GRANT ACCESSCTRL ON DATABASE  TO USER "AJAY";

GRANT BIND ON PACKAGE "NULLID"."AOTMH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."ATSH04" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."DB2XDBMI" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."PRINTSG" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."REVALH04" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SPIMH01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SPUTH01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLA1H00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLA2H00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLA3H00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLA4H00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLA5H00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLABH02" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLC2H22" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLC3H21" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLC4H21" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLC5H21" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLC6H21" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLE3H01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLL9H12" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLP1H02" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUAH19" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUBH05" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUCH05" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUDH02" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUEH01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUFH13" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUHH03" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUIH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUJH0A" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUKH08" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLULH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUMH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUNH01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUOH01" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUPH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUPH03" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SQLUZH00" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH100" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH101" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH102" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH200" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH201" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH202" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH300" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH301" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH302" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH400" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH401" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLH402" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN100" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN101" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN102" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN200" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN201" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN202" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN300" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN301" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN302" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN400" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN401" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSLN402" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH100" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH101" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH102" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH200" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH201" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH202" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH300" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH301" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH302" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH400" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH401" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSH402" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN100" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN101" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN102" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN200" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN201" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN202" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN300" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN301" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN302" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN400" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN401" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSN402" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."SYSSTAT" TO  PUBLIC;

GRANT BIND ON PACKAGE "NULLID"."TUPLEWRT" TO  PUBLIC;

GRANT BINDADD ON DATABASE  TO  PUBLIC;

GRANT CONNECT ON DATABASE  TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "AJAY" TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "DB2ADMIN" TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "NULLID" TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "SQLJ" TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "SYSPUBLIC" TO  PUBLIC;

GRANT CREATEIN ON SCHEMA "SYSTOOLS" TO  PUBLIC;

GRANT CREATETAB ON DATABASE  TO  PUBLIC;

GRANT DATAACCESS ON DATABASE  TO USER "AJAY";

GRANT DBADM ON DATABASE  TO USER "AJAY";

GRANT DROPIN ON SCHEMA "SYSPUBLIC" TO  PUBLIC;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_CONTACTGROUPS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_CONTACTS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_DBP_MEM_USAGE"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_INDEX_COMPRESS_INFO"(VARCHAR(1),VARCHAR(128),VARCHAR(128),INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_INDEX_INFO"(VARCHAR(1),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_MSGS"(VARCHAR(139)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO"(VARCHAR(128),VARCHAR(128),VARCHAR(30)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TAB_COMPRESS_INFO_V97"(VARCHAR(128),VARCHAR(128),VARCHAR(30)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO_V95"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TAB_INFO_V97"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TEMP_COLUMNS"(BIGINT,VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_GET_TEMP_TABLES"(BIGINT,VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_LIST_DB_PATHS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ADMIN_LIST_HIST"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AM_BASE_RPTS"(INTEGER,CHAR(4),VARCHAR(33)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AM_BASE_RPT_RECOMS"(INTEGER,VARCHAR(33)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AUTH_GET_INSTANCE_AUTHID"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AUTH_LIST_AUTHORITIES_FOR_AUTHID"(VARCHAR(128),VARCHAR(1)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AUTH_LIST_GROUPS_FOR_AUTHID"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."AUTH_LIST_ROLES_FOR_AUTHID"(VARCHAR(128),VARCHAR(1)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."BASE_TABLE"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."COMPILATION_ENV"(BLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."DB2LK_DEP_FIRST"(VARCHAR(1),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."DB2LK_DEP_OF"(VARCHAR(1),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."DBM_GET_CFG"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."DB_GET_CFG"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."DB_PARTITIONS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_DB2_SYSTEM_RESOURCES"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_FEATURE_INFO"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_INST_INFO"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_NETWORK_RESOURCES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_PROD_INFO"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_PROD_INFO_V95"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_SYSTEM_RESOURCES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_SYS_INFO"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."ENV_GET_SYS_RESOURCES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EVMON_FORMAT_UE_TO_STREAM"(VARCHAR(1028),INTEGER,VARCHAR(128),VARCHAR(255),VARCHAR (32) FOR BIT DATA,BLOB(5242880),BIGINT,TIMESTAMP,VARCHAR(128),INTEGER,BIGINT,BIGINT,VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EVMON_FORMAT_UE_TO_XML"(VARCHAR(1028),INTEGER,VARCHAR(128),VARCHAR(255),VARCHAR (32) FOR BIT DATA,BLOB(5242880),BIGINT,TIMESTAMP,VARCHAR(128),INTEGER,BIGINT,BIGINT,VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXDYN_DGTT_COLUMN"(INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXDYN_DGTT_IDXCOL"(INTEGER,INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXDYN_DGTT_INDEX"(INTEGER,INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXDYN_DGTT_TABLE"(INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXPLAIN_FORMAT_STATS"(BLOB(10485760)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXPLAIN_GET_MSG"(VARCHAR(33),INTEGER,VARCHAR(1000),VARCHAR(1000),VARCHAR(1000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."EXPLAIN_GET_MSG2"(VARCHAR(33),INTEGER,VARCHAR(1000),VARCHAR(1000),VARCHAR(1000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."GET_INDEX_COLNAMES"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."GET_ROUTINE_OPTS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_CONT_HI"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_CONT_HI_HIS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_CONT_INFO"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DBM_HI"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DBM_HI_HIS"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DBM_INFO"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DB_HI"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DB_HIC"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DB_HIC_HIS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DB_HI_HIS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_DB_INFO"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_GET_ALERT_ACTION_CFG"(VARCHAR(3),VARCHAR(1),VARCHAR(128),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_GET_ALERT_CFG"(VARCHAR(3),VARCHAR(1),VARCHAR(128),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_GET_IND_DEFINITION"(VARCHAR(33)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_GET_NOTIFICATION_LIST"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_TBS_HI"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_TBS_HI_HIS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."HEALTH_TBS_INFO"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."MON_FORMAT_XML_TIMES_BY_ROW"(BLOB(104857600)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."MON_GET_APPLICATION_HANDLE"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."MON_GET_APPLICATION_ID"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."OPT_MIGRATE_PROF"(BLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."PD_GET_DIAG_HIST"(VARCHAR(20),VARCHAR(30),VARCHAR(18),TIMESTAMP,TIMESTAMP) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."PD_GET_LOG_MSGS"(TIMESTAMP) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."POLICY_VALIDATE"(VARCHAR(128),BLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."REG_LIST_VARIABLES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_AGENT"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_APPL"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_APPL_INFO"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_BP"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_CNTRFS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_CONTAINER"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_DATABASE"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_DBM"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_DYN_SQL"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_FCM"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_FCMNODE"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_LOCK"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_LOCKWAIT"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_QUIESCERS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_RANGES"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_STATEMENT"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_SUBSECT"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_SWITCHES"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_TABLE"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_TBREORG"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_TBS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_TBS_CFG"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_UTIL"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAPSHOT_UTIL_PROG"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_AGENT"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_AGENT"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_AGENT_MEMORY_POOL"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO_V95"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_INFO_V95"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_V95"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_APPL_V95"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP_PART"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP_PART"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP_V95"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_BP_V95"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_CONTAINER"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_CONTAINER_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_CONTAINER_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM_MEMORY_POOL"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM_V95"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DBM_V95"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_MEMORY_POOL"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_MEMORY_POOL"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V95"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V95"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V97"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DB_V97"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DETAILLOG_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V95"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_DYN_SQL_V95"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_FCM"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_FCM"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_FCM_PART"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_FCM_PART"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_HADR"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_HADR"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_LOCK"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_LOCK"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_LOCKWAIT"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_LOCKWAIT"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STMT"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STMT"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STORAGE_PATHS_V97"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_STO_PATHS"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_SUBSECTION"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_SUBSECTION"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_SWITCHES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_SWITCHES"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TAB"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TAB_REORG"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TAB_REORG"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TAB_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TAB_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V97"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_PART_V97"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_QUIESCER"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_QUIESCER"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_RANGE"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_RANGE"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_V91"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_TBSP_V91"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_UTIL"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_UTIL"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_UTIL_PROGRESS"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SNAP_GET_UTIL_PROGRESS"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SQLERRM"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON FUNCTION "SYSPROC"."SQLERRM"(VARCHAR(9),VARCHAR(70),VARCHAR(1),VARCHAR(33),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PACKAGE "NULLID"."AOTMH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."ATSH04" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."DB2XDBMI" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."PRINTSG" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."REVALH04" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SPIMH01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SPUTH01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLA1H00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLA2H00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLA3H00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLA4H00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLA5H00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLABH02" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLC2H22" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLC3H21" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLC4H21" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLC5H21" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLC6H21" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLE3H01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLL9H12" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLP1H02" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUAH19" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUBH05" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUCH05" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUDH02" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUEH01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUFH13" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUHH03" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUIH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUJH0A" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUKH08" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLULH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUMH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUNH01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUOH01" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUPH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUPH03" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SQLUZH00" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH100" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH101" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH102" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH200" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH201" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH202" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH300" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH301" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH302" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH400" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH401" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLH402" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN100" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN101" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN102" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN200" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN201" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN202" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN300" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN301" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN302" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN400" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN401" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSLN402" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH100" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH101" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH102" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH200" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH201" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH202" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH300" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH301" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH302" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH400" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH401" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSH402" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN100" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN101" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN102" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN200" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN201" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN202" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN300" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN301" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN302" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN400" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN401" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSN402" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."SYSSTAT" TO  PUBLIC;

GRANT EXECUTE ON PACKAGE "NULLID"."TUPLEWRT" TO  PUBLIC;

GRANT EXECUTE ON PROCEDURE "SQLJ"."DB2_INSTALL_JAR"(BLOB(10485760),VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."DB2_INSTALL_JAR"(BLOB(10485760),VARCHAR(261),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."DB2_REPLACE_JAR"(BLOB(10485760),VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."DB2_UPDATEJARINFO"(VARCHAR(261),VARCHAR(128),BLOB(10485760)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."RECOVERJAR"(VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."REFRESH_CLASSES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."REMOVE_JAR"(VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SQLJ"."REMOVE_JAR"(VARCHAR(261),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSFUN"."GET_ROUTINE_SAR"(BLOB(3145728),CHAR(2),VARCHAR(257)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSFUN"."GET_ROUTINE_SAR"(BLOB(3145728),CHAR(2),VARCHAR(257),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSFUN"."PUT_ROUTINE_SAR"(BLOB(3145728)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSFUN"."PUT_ROUTINE_SAR"(BLOB(3145728),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLATTRIBUTES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLCAMESSAGE"(INTEGER,SMALLINT,VARCHAR(70),CHAR(8),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,CHAR(11),CHAR(5),VARCHAR(20),VARCHAR(33),VARCHAR(4096),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLCAMESSAGECCSID"(INTEGER,SMALLINT,VARCHAR(70),CHAR(8),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,CHAR(11),CHAR(5),VARCHAR(20),VARCHAR(33),VARCHAR(4096),INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLCOLPRIVILEGES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(256),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLCOLUMNS"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(256),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLFOREIGNKEYS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLFUNCTIONCOLS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLFUNCTIONS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLGETTYPEINFO"(SMALLINT,VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLPRIMARYKEYS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLPROCEDURECOLS"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(256),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLPROCEDURES"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLSPECIALCOLUMNS"(SMALLINT,VARCHAR(128),VARCHAR(128),VARCHAR(128),SMALLINT,SMALLINT,VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLSTATISTICS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),SMALLINT,SMALLINT,VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLSUPERTABLES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLSUPERTYPES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLTABLEPRIVILEGES"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLTABLES"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(4000),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBM"."SQLUDTS"(VARCHAR(128),VARCHAR(256),VARCHAR(256),VARCHAR(18),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBMADM"."RAISE_APPLICATION_ERROR"(INTEGER,VARCHAR(2000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSIBMADM"."RAISE_APPLICATION_ERROR"(INTEGER,VARCHAR(2000),BOOLEAN) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_CMD"(CLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_COPY_SCHEMA"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),CLOB(2097152),CLOB(2097152),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_DROP_SCHEMA"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_GET_DEPTREE"(VARCHAR(128),CLOB(2097152),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(32672),VARCHAR(32672),VARCHAR(32672),VARCHAR(32672),VARCHAR(32672),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(32672),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_MOVE_TABLE_UTIL"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),CLOB(10485760)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_REMOVE_MSGS"(VARCHAR(139)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_REVALIDATE_DB_OBJECTS"(VARCHAR(30),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_SP_C2"(VARCHAR(128),VARCHAR(128),VARCHAR(128),BLOB(262144)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_TASK_ADD"(VARCHAR(128),TIMESTAMP,TIMESTAMP,INTEGER,VARCHAR(1024),VARCHAR(128),VARCHAR(128),CLOB(2097152),VARCHAR(512),VARCHAR(254)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_TASK_REMOVE"(VARCHAR(128),TIMESTAMP) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ADMIN_TASK_UPDATE"(VARCHAR(128),TIMESTAMP,TIMESTAMP,INTEGER,VARCHAR(1024),VARCHAR(512),VARCHAR(254)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ALTER_ROUTINE_PACKAGE"(CHAR(2),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ALTOBJ"(VARCHAR(30),VARCHAR(32672),INTEGER,VARCHAR(2048)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_DROP_TASK"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_GET_LOCK_CHNS"(BIGINT,CLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_GET_LOCK_CHN_TB"(BIGINT) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_GET_LOCK_RPT"(BIGINT) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_GET_RPT"(INTEGER,INTEGER,CLOB(32768),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."AM_SAVE_TASK"(CHAR(1),INTEGER,VARCHAR(128),CLOB(32768),CHAR(1),VARCHAR(3893)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ANALYZE_LOG_SPACE"(VARCHAR(128),VARCHAR(128),VARCHAR(128),SMALLINT,VARCHAR(26),CHAR(1),VARCHAR(6000),VARCHAR(6000),VARCHAR(6000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ASN_ADMIN_UTIL"(VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),VARCHAR (32400) FOR BIT DATA,VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),VARCHAR (32400) FOR BIT DATA,VARCHAR(32400),VARCHAR(32400),VARCHAR(32400),INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CANCEL_WORK"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CAPTURE_STORAGEMGMT_INFO"(SMALLINT,VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CREATE_SQL_SAMPLE"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CREATE_STORAGEMGMT_TABLES"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CREATE_V8_SAMPLE"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."CREATE_XML_SAMPLE"(VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DB2LK_CLEAN_TABLE"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DB2LK_GENERATE_DDL"(CLOB(2097152),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DB2LK_TBLNDEP"(VARCHAR(20),VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DB2LOAD"(INTEGER,VARCHAR(32672),VARCHAR(32672),INTEGER,VARCHAR(2048),BIGINT,BIGINT,BIGINT,BIGINT,BIGINT,BIGINT,BIGINT,BIGINT,BIGINT,VARCHAR(32672)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_ENDSESSIONMANAGER"(VARCHAR(128),INTEGER,BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_INITIALIZECLIENT"(VARCHAR(128),INTEGER,BLOB(32768),BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_LOOKUPSESSIONMANAGER"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_PINGSESSIONMANAGER"(VARCHAR(128),INTEGER,BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_RECVCLIENTREPORTS"(VARCHAR(128),INTEGER,BLOB(32768),BLOB(32768),BLOB(32768),BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_RUNSESSIONMANAGER"(INTEGER,INTEGER,BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_SENDCLIENTCOMMANDS"(VARCHAR(128),INTEGER,BLOB(32768),BLOB(32768),BLOB(32768),BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_SENDCLIENTREQUESTS"(VARCHAR(128),INTEGER,BLOB(32768),BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DBG_TERMINATECLIENT"(VARCHAR(128),INTEGER,BLOB(32768),BLOB(32768)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DESIGN_ADVISOR"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(12288),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DNET_INSTALLASSEMBLY"(VARCHAR(1024),VARCHAR(1024),VARCHAR(1024),BLOB(4194304),VARCHAR(1024),INTEGER,VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."DROP_STORAGEMGMT_TABLES"(SMALLINT) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EVMON_FORMAT_UE_TO_TABLES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(1024),VARCHAR(128),VARCHAR(128),VARCHAR(1024),INTEGER,CLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EXDYN_DYNAMIC"(INTEGER,INTEGER,VARCHAR(1000),INTEGER,INTEGER,BLOB(4096),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EXDYN_INCBIND"(INTEGER,VARCHAR(128),VARCHAR(128),CHAR (8) FOR BIT DATA,INTEGER,VARCHAR(1000),INTEGER,INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EXDYN_SQLCACHE"(INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(1000),INTEGER,INTEGER,BLOB(4096),INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EXPLAIN_SQL"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(4096),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."EXPLAIN_SQL_HANDLE"(INTEGER,INTEGER,VARCHAR(33),BLOB(4096),BLOB(4096),BLOB(4096),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GENERATE_DISTFILE"(VARCHAR(128),VARCHAR(128),VARCHAR(255)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_CONFIG"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_DB2_SQLROUTINE_PREOPTS"(VARCHAR(1024),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_DBSIZE_INFO"(TIMESTAMP,BIGINT,BIGINT,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_DB_CONFIG"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_MESSAGE"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_PLAN_HINT"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_SWRD_SETTINGS"(VARCHAR(128),SMALLINT,SMALLINT,VARCHAR(255),VARCHAR(255),BIGINT,SMALLINT,SMALLINT,SMALLINT,SMALLINT,VARCHAR(6000),VARCHAR(6000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_SYSTEM_INFO"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_WRAP_CFG_C"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(2000),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."GET_WRAP_CFG_C2"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(2000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."HASNICKNAMECHANGED"(VARCHAR(128),VARCHAR(128),VARCHAR(128),TIMESTAMP,CHAR(1),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."HEALTH_HI_REC"(INTEGER,INTEGER,VARCHAR(255),INTEGER,VARCHAR(255),INTEGER,VARCHAR(33),BLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ITMAGENT_SET_CONFIG"(VARCHAR(256),INTEGER,VARCHAR(2048),SMALLINT,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_SRVR_NODES"(VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_SRVR_OPTIONS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_SRVR_OPTVALS"(VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_SRVR_TYPES"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_SRVR_VERSIONS"(VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_WRAPPERS"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."LIST_WRAP_OPTIONS"(VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."NICKNAMEINFO"(VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER,VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),CHAR(1),TIMESTAMP,TIMESTAMP,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."NICKNAMEINFO"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),CHAR(1),TIMESTAMP,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."NNSTAT"(VARCHAR(128),VARCHAR(128),VARCHAR(128),CLOB(2097152),CLOB(2097152),SMALLINT,VARCHAR(1000),VARCHAR(2000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."NNSTAT"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(1000),VARCHAR(2000),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ODBC_DISCOVERY"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER,VARCHAR(5),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ODBC_DISCOVERY2"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ODBC_DISCOVERY2_32"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."ODBC_DISCOVERY_32"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER,VARCHAR(5),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."POLICY_INSTALL"(CHAR(1),VARCHAR(128),VARCHAR(128),VARCHAR(128),BLOB(2097152)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."POLICY_INSTALLOC"(CHAR(1),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(2048)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."POLICY_RETRIEVE"(VARCHAR(128),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_CLEAR_SESSION"(DOUBLE,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_GET_LEVEL"(VARCHAR(4000),VARCHAR(4000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_GET_REPORT"(DOUBLE,LONG VARCHAR,LONG VARCHAR FOR BIT DATA,INTEGER,INTEGER,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_INIT_SESSION"(DOUBLE,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_PUT_COMMAND"(DOUBLE,LONG VARCHAR,LONG VARCHAR FOR BIT DATA,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_SET_COMPILEMODE"(INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_SET_DEBUGINFO"(VARCHAR(255),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_SET_SESSION"(DOUBLE,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."PSMD_TERM_SESSION"(DOUBLE,INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REBIND_ROUTINE_PACKAGE"(CHAR(2),VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REBIND_ROUTINE_PACKAGE"(CHAR(2),VARCHAR(386),VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REMOTE_QUERY"(VARCHAR(128),VARCHAR(16),VARCHAR(100),VARCHAR(16),VARCHAR(100),SMALLINT,VARCHAR(300),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REMOTE_QUERY2"(VARCHAR(128),VARCHAR(16),VARCHAR(100),VARCHAR(16),VARCHAR(100),SMALLINT,VARCHAR(300)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REORGCHK_IX_STATS"(CHAR(1),VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."REORGCHK_TB_STATS"(CHAR(1),VARCHAR(261)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SET_CONFIG"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SET_DB2_SQLROUTINE_PREOPTS"(VARCHAR(1024),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SET_PLAN_HINT"(INTEGER,INTEGER,VARCHAR(33),BLOB(33554432),BLOB(4096),BLOB(33554432),BLOB(65536)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SET_ROUTINE_OPTS"(VARCHAR(1024)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SET_SWRD_SETTINGS"(VARCHAR(128),SMALLINT,SMALLINT,VARCHAR(255),VARCHAR(255),BIGINT,SMALLINT,SMALLINT,SMALLINT,SMALLINT,VARCHAR(6000),VARCHAR(6000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SNAPSHOT_FILEW"(SMALLINT,VARCHAR(128),SMALLINT) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SNAP_WRITE_FILE"(VARCHAR(32),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."STEPWISE_REDISTRIBUTE_DBPG"(VARCHAR(128),SMALLINT,SMALLINT) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSINSTALLOBJECTS"(VARCHAR(128),CHAR(1),VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSINSTALLROUTINES"() TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_ADMIN_CMD"(VARCHAR(32000),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_ALTER"(VARCHAR(128),VARCHAR(128),VARCHAR(32000),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_CLEAR_COMMANDLOCKS"(VARCHAR(128),VARCHAR(128),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_CLEAR_EVENTS"(VARCHAR(128),VARCHAR(128),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_CREATE"(VARCHAR(128),VARCHAR(128),VARCHAR(1024),VARCHAR(32000),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_DISABLE"(VARCHAR(128),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_DROP"(VARCHAR(128),VARCHAR(128),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_ENABLE"(VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."SYSTS_UPDATE"(VARCHAR(128),VARCHAR(128),VARCHAR(32000),VARCHAR(33),VARCHAR(32000)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML"(VARCHAR(128),VARCHAR(128),BLOB(1048576),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML100MB"(VARCHAR(128),VARCHAR(128),BLOB(104857600),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML10MB"(VARCHAR(128),VARCHAR(128),BLOB(10485760),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML1GB"(VARCHAR(128),VARCHAR(128),BLOB(1073741824),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML1_5GB"(VARCHAR(128),VARCHAR(128),BLOB(1610612736),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML25MB"(VARCHAR(128),VARCHAR(128),BLOB(26214400),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML2GB"(VARCHAR(128),VARCHAR(128),BLOB(2147483647),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML500MB"(VARCHAR(128),VARCHAR(128),BLOB(524288000),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML50MB"(VARCHAR(128),VARCHAR(128),BLOB(52428800),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXML75MB"(VARCHAR(128),VARCHAR(128),BLOB(78643200),VARCHAR(1024),INTEGER,BLOB(65536),BLOB(65536),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDBDECOMPXMLFROMFILELIST"(VARCHAR(128),VARCHAR(128),BLOB(128),BLOB(131072),INTEGER,INTEGER,INTEGER,BLOB(65536),BLOB(65536),INTEGER,INTEGER,INTEGER,BLOB(1048576)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XDB_DECOMP_XML_FROM_QUERY"(VARCHAR(128),VARCHAR(128),CLOB(1048576),INTEGER,INTEGER,INTEGER,BLOB(65536),BLOB(65536),INTEGER,INTEGER,INTEGER,BLOB(104857600)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_ADDSCHEMADOC"(VARCHAR(128),VARCHAR(128),VARCHAR(1000),BLOB(31457280),BLOB(5242880)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_COMPLETE"(VARCHAR(128),VARCHAR(128),BLOB(5242880),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_DTD"(VARCHAR(128),VARCHAR(128),VARCHAR(1000),VARCHAR(1000),BLOB(5242880)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_EXTENTITY"(VARCHAR(128),VARCHAR(128),VARCHAR(1000),VARCHAR(1000),BLOB(5242880)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_GET_PARSING_DIAGNOSTICS"(BLOB(31457280),VARCHAR(128),VARCHAR(128),VARCHAR(1000),INTEGER,VARCHAR(32000),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_REGISTER"(VARCHAR(128),VARCHAR(128),VARCHAR(1000),BLOB(31457280),BLOB(5242880)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_REMOVE"(VARCHAR(128),VARCHAR(128)) TO  PUBLIC WITH GRANT OPTION;

GRANT EXECUTE ON PROCEDURE "SYSPROC"."XSR_UPDATE"(VARCHAR(128),VARCHAR(128),VARCHAR(128),VARCHAR(128),INTEGER) TO  PUBLIC WITH GRANT OPTION;

GRANT IMPLICIT_SCHEMA ON DATABASE  TO  PUBLIC;

GRANT SECADM ON DATABASE  TO USER "AJAY";

GRANT SELECT ON TABLE "SYSCAT"."ATTRIBUTES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."AUDITPOLICIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."AUDITUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."BUFFERPOOLDBPARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."BUFFERPOOLNODES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."BUFFERPOOLS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CASTFUNCTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CHECKS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLCHECKS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLGROUPCOLS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLGROUPDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLGROUPDISTCOUNTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLIDENTATTRIBUTES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLLATIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."COLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CONDITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CONSTDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CONTEXTATTRIBUTES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."CONTEXTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DATAPARTITIONEXPRESSION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DATAPARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DATATYPEDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DATATYPES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DBAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DBPARTITIONGROUPDEF" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."DBPARTITIONGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."EVENTMONITORS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."EVENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."EVENTTABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FULLHIERARCHIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCMAPOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCMAPPARMOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."FUNCTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."HIERARCHIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."HISTOGRAMTEMPLATEBINS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."HISTOGRAMTEMPLATES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."HISTOGRAMTEMPLATEUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXCOLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXEXPLOITRULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXEXTENSIONDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXEXTENSIONMETHODS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXEXTENSIONPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXEXTENSIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXPARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INDEXXMLPATTERNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."INVALIDOBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."KEYCOLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."LIBRARIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."LIBRARYAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."LIBRARYBINDFILES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."LIBRARYVERSIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."MODULEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."MODULEOBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."MODULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."NAMEMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."NICKNAMES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."NODEGROUPDEF" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."NODEGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PACKAGEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PACKAGEDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PACKAGES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PARTITIONMAPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PASSTHRUAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PREDICATESPECS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PROCEDURES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."PROCPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."REFERENCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROLEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINEDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINEOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINEPARMOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINEPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROUTINESFEDERATED" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."ROWFIELDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SCHEMAAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SCHEMATA" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYLABELACCESS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYLABELCOMPONENTELEMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYLABELCOMPONENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYLABELS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYPOLICIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYPOLICYCOMPONENTRULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SECURITYPOLICYEXEMPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SEQUENCEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SEQUENCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SERVEROPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SERVERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SERVICECLASSES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."STATEMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."SURROGATEAUTHIDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABCONST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABDETACHEDDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABLESPACES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TABOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TBSPACEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."THRESHOLDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TRANSFORMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TRIGDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TRIGGERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."TYPEMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."USEROPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."VARIABLEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."VARIABLEDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."VARIABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."VIEWDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."VIEWS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKACTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKACTIONSETS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKCLASSES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKCLASSSETS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKLOADAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKLOADCONNATTR" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WORKLOADS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WRAPOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."WRAPPERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XDBMAPGRAPHS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XDBMAPSHREDTREES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XMLSTRINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTCOMPONENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTDETAILS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTHIERARCHIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSCAT"."XSROBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."CHECK_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."COLUMNS_S" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."DUAL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."PARAMETERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."PARAMETERS_S" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."REFERENTIAL_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."REF_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."ROUTINES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."ROUTINES_S" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLCOLPRIVILEGES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLCOLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLFOREIGNKEYS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLPRIMARYKEYS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLPROCEDURECOLS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLPROCEDURES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLSCHEMAS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLSPECIALCOLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLSTATISTICS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLTABLEPRIVILEGES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLTABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLTABLETYPES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLTYPEINFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SQLUDTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSATTRIBUTES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSAUDITPOLICIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSAUDITUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSBUFFERPOOLNODES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSBUFFERPOOLS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCHECKS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCODEPROPERTIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLCHECKS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLGROUPDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLGROUPDISTCOUNTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLGROUPSCOLS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLLATIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLPROPERTIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCOMMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCONSTDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCONTEXTATTRIBUTES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSCONTEXTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDATAPARTITIONEXPRESSION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDATAPARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDATATYPES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDBAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDEPENDENCIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSDUMMY1" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSEVENTMONITORS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSEVENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSEVENTTABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSFUNCMAPOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSFUNCMAPPARMOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSFUNCMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSFUNCPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSFUNCTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSHIERARCHIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATEBINS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSHISTOGRAMTEMPLATEUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXCOLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXEXPLOITRULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXEXTENSIONMETHODS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXEXTENSIONPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXEXTENSIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXPARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINDEXXMLPATTERNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSINVALIDOBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSJARCONTENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSJAROBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSJOBS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSKEYCOLUSE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSLIBRARIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSLIBRARYAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSLIBRARYBINDFILES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSLIBRARYVERSIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSMODULEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSMODULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSNAMEMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSNODEGROUPDEF" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSNODEGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPARTITIONMAPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPASSTHRUAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPLAN" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPLANAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPLANDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPREDICATESPECS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPROCEDURES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSPROCPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSRELS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSREVTYPEMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROLEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEPARMOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEPARMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEPROPERTIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINEPROPERTIESJAVA" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSROUTINES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSCHEMAAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSCHEMATA" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECTION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYLABELACCESS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYLABELCOMPONENTELEMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYLABELCOMPONENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYLABELS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYPOLICIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYPOLICYCOMPONENTRULES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSECURITYPOLICYEXEMPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSEQUENCEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSEQUENCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSERVEROPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSERVERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSERVICECLASSES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSTMT" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSSURROGATEAUTHIDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTABAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTABCONST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTABLESPACES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTABOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTASKS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTBSPACEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTHRESHOLDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTRANSFORMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTRIGGERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTUNINGINFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSTYPEMAPPINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSUSERAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSUSEROPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSVARIABLEAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSVARIABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSVERSIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSVIEWDEP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSVIEWS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKACTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKACTIONSETS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKCLASSES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKCLASSSETS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKLOADAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKLOADCONNATTR" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWORKLOADS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWRAPOPTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSWRAPPERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXDBMAPGRAPHS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXDBMAPSHREDTREES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXMLPATHS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXMLSTRINGS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXSROBJECTAUTH" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXSROBJECTCOMPONENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXSROBJECTHIERARCHIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."SYSXSROBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."TABLES_S" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."TABLE_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."UDT_S" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."USER_DEFINED_TYPES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBM"."VIEWS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ADMINTABCOMPRESSINFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ADMINTABINFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ADMINTEMPCOLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ADMINTEMPTABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_ALL_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_ARGUMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_CATALOG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_COL_COMMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_CONS_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_DEPENDENCIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_ERRORS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_IND_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_IND_PARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_OBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_PART_INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_PART_KEY_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_PART_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_PROCEDURES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_SEQUENCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_SOURCE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_SYNONYMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_COL_STATISTICS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_COMMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_PARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS_MADE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS_RECD" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_TRIGGERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_VIEWS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ALL_VIEW_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."APPLICATIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."APPL_PERFORMANCE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."AUTHORIZATIONIDS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."BP_HITRATIO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."BP_READ_IO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."BP_WRITE_IO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."CONTACTGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."CONTACTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."CONTAINER_UTILIZATION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DBCFG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DBMCFG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DBPATHS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DB_HISTORY" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DICTIONARY" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."DICT_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ENV_FEATURE_INFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ENV_INST_INFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ENV_PROD_INFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ENV_SYS_INFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ENV_SYS_RESOURCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."LOCKS_HELD" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."LOCKWAITS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."LOG_UTILIZATION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."LONG_RUNNING_SQL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."NOTIFICATIONLIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."OBJECTOWNERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."PDLOGMSGS_LAST24HOURS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."PRIVILEGES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."QUERY_PREP_COST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."REG_VARIABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ROLE_ROLE_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ROLE_SYS_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."ROLE_TAB_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SESSION_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SESSION_ROLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPAGENT" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPAGENT_MEMORY_POOL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPAPPL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPAPPL_INFO" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPBP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPBP_PART" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPCONTAINER" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDB" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDBM" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDBM_MEMORY_POOL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDB_MEMORY_POOL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDETAILLOG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPDYN_SQL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPFCM" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPFCM_PART" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPHADR" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPLOCK" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPLOCKWAIT" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPSTMT" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPSTORAGE_PATHS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPSUBSECTION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPSWITCHES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTAB" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTAB_REORG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTBSP" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTBSP_PART" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTBSP_QUIESCER" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPTBSP_RANGE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPUTIL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."SNAPUTIL_PROGRESS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."TAB" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."TBSP_UTILIZATION" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."TOP_DYNAMIC_SQL" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_ALL_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_ARGUMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_CATALOG" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_COL_COMMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_CONSTRAINTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_CONS_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_DEPENDENCIES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_ERRORS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_IND_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_IND_PARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_OBJECTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_PART_INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_PART_KEY_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_PART_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_PROCEDURES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_ROLE_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_SEQUENCES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_SOURCE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_SYNONYMS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_SYS_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TABLES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TABLESPACES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_COL_STATISTICS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_COMMENTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_PARTITIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS_MADE" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS_RECD" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_TRIGGERS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_VIEWS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSIBMADM"."USER_VIEW_COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."COLDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."COLGROUPDIST" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."COLGROUPDISTCOUNTS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."COLGROUPS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."COLUMNS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."FUNCTIONS" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."INDEXES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."ROUTINES" TO  PUBLIC;

GRANT SELECT ON TABLE "SYSSTAT"."TABLES" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."COLDIST" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."COLGROUPDIST" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."COLGROUPDISTCOUNTS" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."COLGROUPS" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."COLUMNS" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."FUNCTIONS" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."INDEXES" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."ROUTINES" TO  PUBLIC;

GRANT UPDATE ON TABLE "SYSSTAT"."TABLES" TO  PUBLIC;

COMMENT ON TABLE "SYSIBMADM"."ALL_ALL_TABLES" IS
'Description of relational tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_ARGUMENTS" IS
'Arguments in objects accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_CATALOG" IS
'All accessible tables, views and synonyms';

COMMENT ON TABLE "SYSIBMADM"."ALL_COL_COMMENTS" IS
'Comments on columns of accessible tables and views';

COMMENT ON TABLE "SYSIBMADM"."ALL_CONSTRAINTS" IS
'Constraint definitions on accessible tables';

COMMENT ON TABLE "SYSIBMADM"."ALL_CONS_COLUMNS" IS
'Information about columns in constraint definitions in accessible tables';

COMMENT ON TABLE "SYSIBMADM"."ALL_DEPENDENCIES" IS
'Dependencies to and from objects accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_ERRORS" IS
'Objects accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_INDEXES" IS
'Description of indexes on tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_IND_COLUMNS" IS
'COLUMNs comprising INDEXes on accessible TABLEs';

COMMENT ON TABLE "SYSIBMADM"."ALL_IND_PARTITIONS" IS
'Description of partitioned-level partitioning information for index partitions accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_OBJECTS" IS
'Objects accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_PART_INDEXES" IS
'Description of partitioned tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_PART_KEY_COLUMNS" IS
'Description of partitioning key columns for the partitioned objects accessible to the current user';

COMMENT ON TABLE "SYSIBMADM"."ALL_PART_TABLES" IS
'Description of partitioned tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_PROCEDURES" IS
'Description of all procedures available to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_SEQUENCES" IS
'Description of SEQUENCEs accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_SOURCE" IS
'Current source on stored objects that the user is allowed to create';

COMMENT ON TABLE "SYSIBMADM"."ALL_SYNONYMS" IS
'All synonyms accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TABLES" IS
'Description of relational tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_COLUMNS" IS
'Columns of tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_COL_STATISTICS" IS
'Column statistics for columns of tables accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_COMMENTS" IS
'Comments on tables and views accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_PARTITIONS" IS
'Description of partitioned-level partitioning information for table partitions accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS" IS
'Grants on objects for which the user is the grantor, grantee, owner, or PUBLIC is the grantee';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS_MADE" IS
'User''s grants and grants on user''s objects';

COMMENT ON TABLE "SYSIBMADM"."ALL_TAB_PRIVS_RECD" IS
'Grants on objects for which the user or PUBLIC is the grantee';

COMMENT ON TABLE "SYSIBMADM"."ALL_TRIGGERS" IS
'Triggers accessible to the current user';

COMMENT ON TABLE "SYSIBMADM"."ALL_VIEWS" IS
'Description of views accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."ALL_VIEW_COLUMNS" IS
'Columns of views accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."DBA_ALL_TABLES" IS
'Description of all relational tables in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_ARGUMENTS" IS
'Arguments in all objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_CATALOG" IS
'All database tables, views and synonyms';

COMMENT ON TABLE "SYSIBMADM"."DBA_COL_COMMENTS" IS
'Comments on columns of all tables and views';

COMMENT ON TABLE "SYSIBMADM"."DBA_CONSTRAINTS" IS
'Constraint definitions on all tables';

COMMENT ON TABLE "SYSIBMADM"."DBA_CONS_COLUMNS" IS
'Information about all columns in constraint definitions';

COMMENT ON TABLE "SYSIBMADM"."DBA_DEPENDENCIES" IS
'Dependencies to and from objects';

COMMENT ON TABLE "SYSIBMADM"."DBA_ERRORS" IS
'Current errors on all stored objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_INDEXES" IS
'Description for all indexes in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_IND_COLUMNS" IS
'COLUMNs comprising INDEXes on all TABLEs';

COMMENT ON TABLE "SYSIBMADM"."DBA_IND_PARTITIONS" IS
'Description of partitioned-level partitioning information for all index partitions in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_OBJECTS" IS
'All objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_PART_INDEXES" IS
'Description of all partitioned indexes in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_PART_KEY_COLUMNS" IS
'Description of the partitioning key columns for all partitioned objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_PART_TABLES" IS
'Description of all partitioned tables in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_PROCEDURES" IS
'Description of all procedures';

COMMENT ON TABLE "SYSIBMADM"."DBA_ROLES" IS
'All roles which exist in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_ROLE_PRIVS" IS
'Roles granted to users and roles';

COMMENT ON TABLE "SYSIBMADM"."DBA_SEQUENCES" IS
'Description of all SEQUENCEs in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_SOURCE" IS
'Source of all stored objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_SYNONYMS" IS
'All synonyms in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_SYS_PRIVS" IS
'System privileges granted to users and roles';

COMMENT ON TABLE "SYSIBMADM"."DBA_TABLES" IS
'Description of all relational tables in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TABLESPACES" IS
'Description of all tablespaces';

COMMENT ON TABLE "SYSIBMADM"."DBA_TAB_COLUMNS" IS
'Columns of all tables in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TAB_COL_STATISTICS" IS
'Column statistics for columns of all tables in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TAB_COMMENTS" IS
'Comments on all tables and views in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TAB_PARTITIONS" IS
'Description of partitioned-level partitioning information for all table partitions in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TAB_PRIVS" IS
'All grants on objects in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_TRIGGERS" IS
'All triggers in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_VIEWS" IS
'Description of all views in the database';

COMMENT ON TABLE "SYSIBMADM"."DBA_VIEW_COLUMNS" IS
'Columns of all views in the database';

COMMENT ON TABLE "SYSIBMADM"."DICTIONARY" IS
'Description of data dictionary tables and views';

COMMENT ON TABLE "SYSIBMADM"."DICT_COLUMNS" IS
'Description of columns in data dictionary tables and views';

COMMENT ON TABLE "SYSIBMADM"."ROLE_ROLE_PRIVS" IS
'Roles which are granted to roles';

COMMENT ON TABLE "SYSIBMADM"."ROLE_SYS_PRIVS" IS
'System privileges granted to roles';

COMMENT ON TABLE "SYSIBMADM"."ROLE_TAB_PRIVS" IS
'Table privileges granted to roles';

COMMENT ON TABLE "SYSIBMADM"."SESSION_PRIVS" IS
'Privileges which the user currently has set';

COMMENT ON TABLE "SYSIBMADM"."SESSION_ROLES" IS
'Roles which the user currently has enabled';

COMMENT ON TABLE "SYSIBMADM"."TAB" IS
'Description of the user''s own relational tables, views, and synonyms';

COMMENT ON TABLE "SYSIBMADM"."USER_ALL_TABLES" IS
'Description of the user''s own relational tables';

COMMENT ON TABLE "SYSIBMADM"."USER_ARGUMENTS" IS
'Arguments in objects owned by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_CATALOG" IS
'All user''s own tables, views and synonyms';

COMMENT ON TABLE "SYSIBMADM"."USER_COL_COMMENTS" IS
'Comments on columns of user''s tables and views';

COMMENT ON TABLE "SYSIBMADM"."USER_CONSTRAINTS" IS
'Constraint definitions on user''s own tables';

COMMENT ON TABLE "SYSIBMADM"."USER_CONS_COLUMNS" IS
'Information about columns in constraint definitions in user''s own tables';

COMMENT ON TABLE "SYSIBMADM"."USER_DEPENDENCIES" IS
'Dependencies to and from a user''s objects';

COMMENT ON TABLE "SYSIBMADM"."USER_ERRORS" IS
'Current errors on stored objects owned by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_INDEXES" IS
'Description of the user''s own indexes';

COMMENT ON TABLE "SYSIBMADM"."USER_IND_COLUMNS" IS
'COLUMNs comprising user''s INDEXes and INDEXes on user''s TABLEs';

COMMENT ON TABLE "SYSIBMADM"."USER_IND_PARTITIONS" IS
'Description of partitioned-level partitioning information for the user''s own index partitions';

COMMENT ON TABLE "SYSIBMADM"."USER_OBJECTS" IS
'Objects owned by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_PART_INDEXES" IS
'Description of the user''s own partitioned indexes';

COMMENT ON TABLE "SYSIBMADM"."USER_PART_KEY_COLUMNS" IS
'Description of the partitioning key columns for the user''s own partitioned objects';

COMMENT ON TABLE "SYSIBMADM"."USER_PART_TABLES" IS
'Description of the user''s own partitioned tables';

COMMENT ON TABLE "SYSIBMADM"."USER_PROCEDURES" IS
'Description of the user''s own procedures';

COMMENT ON TABLE "SYSIBMADM"."USER_ROLE_PRIVS" IS
'Roles granted to current user';

COMMENT ON TABLE "SYSIBMADM"."USER_SEQUENCES" IS
'Description of the user''s own SEQUENCEs';

COMMENT ON TABLE "SYSIBMADM"."USER_SOURCE" IS
'Source of stored objects accessible to the user';

COMMENT ON TABLE "SYSIBMADM"."USER_SYNONYMS" IS
'The user''s private synonyms';

COMMENT ON TABLE "SYSIBMADM"."USER_SYS_PRIVS" IS
'System privileges granted to current user';

COMMENT ON TABLE "SYSIBMADM"."USER_TABLES" IS
'Description of the user''s own relational tables';

COMMENT ON TABLE "SYSIBMADM"."USER_TABLESPACES" IS
'Description of accessible tablespaces';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_COLUMNS" IS
'Columns of user''s tables';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_COL_STATISTICS" IS
'Columns statistics for columns of user''s tables';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_COMMENTS" IS
'Comments on tables and views owned by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_PARTITIONS" IS
'Description of partitioned-level partitioning information for the user''s own table partitions';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS" IS
'Grants on objects for which the user is the owner';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS_MADE" IS
'All grants on objects owner by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_TAB_PRIVS_RECD" IS
'Grants on objects for which the user is the grantee';

COMMENT ON TABLE "SYSIBMADM"."USER_TRIGGERS" IS
'Triggers owned by the user';

COMMENT ON TABLE "SYSIBMADM"."USER_VIEWS" IS
'Description of the user''s own views';

COMMENT ON TABLE "SYSIBMADM"."USER_VIEW_COLUMNS" IS
'Columns of user''s views';
